PYTHONPATH

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Fri Apr 15 05:51:56 EDT 2011


En Fri, 15 Apr 2011 05:33:18 -0300, Algis Kabaila <akabaila at pcug.org.au>  
escribió:

> An elementary question that is bugging me, regarding sys.path
> values.sys.path can be altered easily, but the changes last for
> the current session only. I would like the changes to stay for
> several sessions.  Is PYTHONPATH a system variable that sets the
> path for several sessions and if so, where in the system is it?
> Do I need to create one for setting python path for several
> sessions?

PYTHONPATH is an environment variable, you set it the same way as any  
other, the details depend on the operating system/shell you're currently  
using.

But - why do you think you need to set PYTHONPATH? Don't do that. Use the  
standard places to put your library modules and packages, like  
site-packages (where third-party libraries are installed by default). From  
Python 2.6+ the search path includes per-user directories like  
~/.local/lib/python2.6/site-packages and  
%APPDATA%\Python\Python26\site-packages (see PEP370 [1] for details) so  
you don't even have to mess with the Python installation directories.


[1] http://www.python.org/dev/peps/pep-0370/

-- 
Gabriel Genellina




More information about the Python-list mailing list