Where does IDLE expect to find imported files?
Brad Bollenbach
bbollenbach at shaw.ca
Wed May 22 21:24:21 EDT 2002
"CarolineBlue" <Midnightblue3 at btinternet.com> wrote in
news:ach90f$141$1 at knossos.btinternet.com:
> BlankCan't get import to work - need to know correct directory to put
> .py files in for processing
>
> I have just installed Python 2.2.1 under Windows 98SE (from a Computer
> Shopper CD). I am working my way through the Tutorial, but cannot
> import files for processing by IDLE. Where does IDLE expect to find
> the named file (eg. prog.py), so that "import prog.py" will work?
The details of where Python will look are platform specific.
Generally, it will first look to see if the module is a builtin, and from
there proceed to search sys.path to find the module you're trying to
import. So, on my Windows ME box, sys.path can be examined as follows:
>>> import sys
>>> print sys.path
['', 'C:\\PYTHON22\\lib\\site-packages\\win32', 'C:\\PYTHON22\\lib\\site-
packages\\win32\\lib', 'C:\\PYTHON22\\lib\\site-packages',
'C:\\PYTHON22\\lib\\site-packages\\Pythonwin', 'C:\\PYTHON22\\DLLs',
'C:\\PYTHON22\\lib', 'C:\\PYTHON22\\lib\\lib-tk', 'C:\\PYTHON22']
>>>
Hope that helps.
--
Brad Bollenbach
More information about the Python-list
mailing list