[Tutor] problem resulting from installing 3.0

Alan Gauld alan.gauld at btinternet.com
Sun Sep 2 16:15:48 CEST 2007


"Kent Johnson" <kent37 at tds.net> wrote

> PYTHONPATH is for your own customizations of sys.path, it is not the
> entirety of sys.path. AFAIK you don't have to define it at all if 
> you
> don't want to use it.

All true. The point of PYTHONPATH is that you could have several
users all running python on the same box (either concurrently on
a server or different users ion the same PC at different times)
PYTHONPATH allows each user to have their own custom
additions to sys.path.

> There are quite a few ways to get a module into the search path,
> modifying PYTHONPATH is just one way. Some others:
> - create a site-packages/ dir in the Python lib dir. Put your 
> modules
> and packages there and they will be found by Python.

Usually used for non standard packages like wxPython, pyGame etc
that all users will want to have available

> - add a .pth file to site-packages/ that contains the path to the 
> dir
> you want to add to sys.path

Similar to above but allows different Python installs on the same
machine to share the same library.

> - modify sys.path directly in code.

This is best if only one (or a very few) application needs access
to the modules. Especially if they are intended to mask standard
modules like os.

So use PYTHONPATH for individual tailoring and sitepackages etc
for site wide changes.

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 




More information about the Tutor mailing list