adding new paths to sys.path

Alex Martelli aleax at aleax.it
Fri Mar 7 03:25:17 EST 2003


Jp Calderone wrote:

> On Fri, Mar 07, 2003 at 12:57:07PM +0800, Jon Perez wrote:
>> Under Slackware Linux, I've installed Python
>> modules in /usr/local/lib/python2.2/site-packages
>> instead of /usr/lib/python2.2/site-packages and
>> now Python can't find the newer modules.
>> 
>> In the interactive command line, I can always
>> add this new directory to sys.path, however,
>> that won't do for scripts run from the command
>> line.
>> 
>> What do I change to get these new package paths
>> added to the default paths searched by Python
>> when running a script?
>> 
> 
>   In order of increasing suckfulness:

0) add a textfile /usr/lib/python2.2/site-packages/whatever.pth 
including the single line:
/usr/local/lib/python2.2/site-packages

Name 'whatever' is arbitrary, it's the .pth extension that matters.


>     1) Move the packages from /usr/local/lib/python2.2/site-packages/ to
>     /usr/lib/python2.2/site-packages/
> 
>     2) Add /usr/local/lib/python2.2/site-packages/ to sys.path in
>     /usr/lib/python2.2/site-packages/sitecustomize.py
> 
>     3) Add /usr/local/lib/python2.2/site-packages/ to your PYTHONPATH env
>     var


Alex





More information about the Python-list mailing list