sys.path Problem with 2.2?

Justin Doak jdoak at lanl.gov
Tue Feb 19 18:47:38 EST 2002


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