sys.path Problem with 2.2?

Justin Doak jdoak at lanl.gov
Wed Feb 20 13:09:17 EST 2002


Doh! I was trying to add $HOME/python/lib to the PYTHONPATH when what
I _meant_ to do was add $HOME/lib/python. The interpreter was smart
enough not to add a directory that didn't exist to the module search
path. This seems to be an argument for pair programming. I looked at
the PYTHONPATH a hundred times without seeing this problem. Someone
else would've seen it immediately.

JD

jdoak at lanl.gov (Justin Doak) wrote in message news:<3d7957d4.0202191547.1f13d03b at posting.google.com>...
> I add a directory to my PYTHONPATH, but when I fire up the
> interpreter, sys.path is getting the old value for PYTHONPATH. I ran
> 2.1, and it seems to be loading up the new PYTHONPATH just fine. 2.2
> also seems to know when my PYTHONPATH is set or not; when I unset it,
> nothing from the PYTHONPATH shows up in sys.path. This is decidedly
> strange behavior; is there some caching of the PYTHONPATH going on
> somewhere/somehow?
> 
> JD
> 
> # sys.path doesn't get all the directories from PYTHONPATH.
> 
> 134 doak->doak% echo $PYTHONPATH
> .:/n/toaster/u/doak/cvs/computer_vision:/n/toaster/u/doak/python/lib
> 135 doak->doak% python
> Python 2.2 (#1, Jan  4 2002, 14:14:33)
> [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import sys
> >>> sys.path
> ['', '/nh/toaster/u/doak', '/n/toaster/u/doak/cvs/computer_vision',
> '/packages/lib/python2.2', '/packages/lib/python2.2/plat-linux2',
> '/packages/lib/python2.2/lib-tk',
> '/packages/lib/python2.2/lib-dynload',
> '/packages/lib/python2.2/site-packages',
> '/packages/lib/python2.2/site-packages/Numeric']
> 
> # But sys.path knows when I've unset PYTHONPATH.
> 
> 136 doak->doak% unsetenv PYTHONPATH
> 137 doak->doak% python
> Python 2.2 (#1, Jan  4 2002, 14:14:33)
> [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import sys
> >>> sys.path
> ['', '/packages/lib/python2.2', '/packages/lib/python2.2/plat-linux2',
> '/packages/lib/python2.2/lib-tk',
> '/packages/lib/python2.2/lib-dynload',
> '/packages/lib/python2.2/site-packages',
> '/packages/lib/python2.2/site-packages/Numeric']
> 
> # 2.1 reads the PYTHONPATH correctly.
> 
> 141 doak->doak% source ~/.cshrc
> 142 doak->doak% echo $PYTHONPATH
> .:/n/toaster/u/doak/cvs/computer_vision:/n/toaster/u/doak/python/lib
> 143 doak->doak% /packages/.packages/python/python-2.1/bin/linux/python
> Python 2.1 (#1, Jun  8 2001, 09:50:58)
> [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2
> Type "copyright", "credits" or "license" for more information.
> >>> import sys
> >>> sys.path
> ['', '/nh/toaster/u/doak', '/n/toaster/u/doak/cvs/computer_vision',
> '/n/toaster/u/doak/python/lib', '/packages/lib/python2.1',
> '/packages/lib/python2.1/plat-linux2',
> '/packages/lib/python2.1/lib-tk',
> '/packages/lib/python2.1/lib-dynload',
> '/packages/lib/python2.1/site-packages',
> '/packages/lib/python2.1/site-packages/Numeric']



More information about the Python-list mailing list