[Tutor] PYTHONPATH - PATHS, again

alan.gauld@bt.com alan.gauld@bt.com
Thu, 6 Dec 2001 17:25:31 -0000


> I have seen reference to PYTHONPATH in various websites, specifically 
> having to do with module set up. What is PYTHONPATH? How is it used?

It is a pointer to tell python where to find the modules that
are imported by programs. It is similar to the program PATH used 
by the OS to find the executable files to run.

Thus when python comes out of the box it sets its home directory 
and knows to look there for builtin modules. But if you 
download extension modules or write your own it doesn't know 
where to look for them. Thus it looks at the directories 
listed in PYTHONPATH.

It is st as an environment variable(see my other post)

> Incidentally, I relate this to the PATH statement in the 
> AUTOEXEC.BAT in the DOS/Windows environment, 

Same format but different name. It does a very similar job.
FWIW here's mine from AUTROEXEC.BAT:

set PYTHONPATH=D:\PROJECTS\PYTHON;D:\LIBS\PYTHON

Thus I keep any modules I've finished in LIBS\PYTHON and 
new work under construction will be in Projects\Python.

Alan G.