Pythonpath in Windows

Peter Hansen peter at engcorp.com
Mon Jan 29 00:46:58 EST 2001


Mike Callahan wrote:
> 
> I would like to get my windows python 2.0 to be able to import any script
> that is in the current working directory. Do I need to add '.' to the
> pythonpath in the registry? Is that the only thing?

Getting scripts in the current directory to be imported
is a tricky and involved procedure that goes like this:

 1. Import the script

Phew!  :)

That works on my machine, anyway, with what is I believe a
default Python 2.0 install under Win NT.

Actually, if the current directory is not already in the path, you
will have to add it somehow.  First thing to do is to check the
path from the interactive mode:

>>> import sys
>>> sys.path
['', 'c:\\', 'n:\\a\\python\\dlls', 'n:\\a\\python\\lib', 
'n:\\a\\python\\lib\\plat-win', 'n:\\a\\python\\lib\\lib-tk', 
'n:\\a\\python', 'n:\\lib\\python']

You need that first entry (doesn't have to be first, but the
directories are search in order) or .py files in the current
directory are not found by import.



More information about the Python-list mailing list