[Tutor] Where does python look for import files

Kirby Urner urnerk@qwest.net
Fri, 19 Apr 2002 20:54:27 -0400


On Friday 19 April 2002 09:54 pm, ncoulter@es.com wrote:
> I apologize if this is documented in some obvious place, but I have spent
> all day looking for this information, and have yet to find it:
>
> What procedure/variables does python use to search for files in import
> commands?  I see that sys.path contains a list of paths, but am not sure
> how to modify it.  My goal right now is to set up a folder
> (c:\python22\scripts) where I can create a folder tree python will search
> when it encounters an import command.

You should find c:\python22\lib\site-packages in your windows 
tree.   That's a better place to put your 3rd party stuff.

But if you want to augment the standard tree with other locations,
in WIndows you have the option to create .pth files, e.g. init.pth,
where you can list additional paths, e.g. if you have a subdirectory
of \python22 names scripts, just create init.pth with the one word
scripts in it, and nothing more.

Kirby