How is sys.path initialized without a PYTHONPATH?

Jeff Hinrichs jlh at home.com
Sun Dec 2 01:22:17 EST 2001


Quote from
http://www.activestate.com/Corporate/Events/Speeches/extensions.pdf

"sys.path is the path which is traversed when looking for a module (during
an import):
>>> import sys
>>> sys.path
['', 'h:\\David\\py', 'C:\\Program Files\\Python, ...]
. '' refers to the current directory.
. The search is sequential left to right until success (or end is reached)
. Value at startup determined by PYTHONPATH env't variable & Registry on
win32
. Can be dynamically changed:
>>> sys.path.insert(0, '/home/da/python')
. Special .pth files placed in key directories can modify the path as well!
"
----- Original Message -----
From: "A. Keyton Weissinger" <keyton at weissinger.org>
To: <python-list at python.org>
Sent: Saturday, December 01, 2001 11:03 PM
Subject: How is sys.path initialized without a PYTHONPATH?


> I am using ActiveState's ActivePython 2.1. I do NOT have a PYTHONPATH
> environment variable set on my machine. When I fire up the interpreter
> shell, and do the following:
>
> >>> import sys
> >>> print sys.path
>
> I get the following:
>
> ['', 'C:\\Python21\\Pythonwin', 'C:\\Python21\\win32',
> 'C:\\Python21\\win32\\Lib', 'C:\\Python21', 'C:\\Python21\\DLLs',
> 'C:\\Python21\\lib', 'C:\\Python21\\lib\\plat-win',
> 'C:\\Python21\\lib\\lib-tk', 'C:\\Python21\\Numeric', 'C:\\Python21\\PPM']
>
> Where is the list being generated since I have no PYTHONPATH variable? Can
I
> configure this somehow to include more places (without having to append()
to
> the sys.path in the interpreter shell)?
>
> Thank you...
>
> Keyton
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>





More information about the Python-list mailing list