Import, how to change sys.path on Windows, and module naming?

Steve Holden steve at holdenweb.com
Sat Mar 1 14:17:26 EST 2008


Jeremy Nicoll - news posts wrote:
> Jeremy Nicoll - news posts <jn.nntp.scrap001 at wingsandbeaks.org.uk> wrote:
> 
>> If I understand correctly, when I import something under Windows, Python
>> searches the directory that the executing script was loaded from, then
>> other directories as specified in "sys.path".
> 
> Sorry to followup my own question, but I ran
> 
>  for p,q in enumerate(sys.path): print p, q
> 
> and got:
> 
> 0 C:\Documents and Settings\Laptop\My Documents\JN_PythonPgms
> 1 C:\Program Files\~P-folder\Python25\Lib\idlelib
> 2 C:\WINDOWS\system32\python25.zip
> 3 C:\Program Files\~P-folder\Python25\DLLs
> 4 C:\Program Files\~P-folder\Python25\lib
> 5 C:\Program Files\~P-folder\Python25\lib\plat-win
> 6 C:\Program Files\~P-folder\Python25\lib\lib-tk
> 7 C:\Program Files\~P-folder\Python25
> 8 C:\Program Files\~P-folder\Python25\lib\site-packages
> 9 C:\Program Files\~P-folder\Python25\lib\site-packages\win32
> 10 C:\Program Files\~P-folder\Python25\lib\site-packages\win32\lib
> 11 C:\Program Files\~P-folder\Python25\lib\site-packages\Pythonwin
> 
> Does every Windows user have: 2 C:\WINDOWS\system32\python25.zip
> in their sys.path?  What's the point of having a zip in the path?
> 
So that the files inside the zip can be imported as modules and 
packsges, of course.

> Also, looking in  C:\WINDOWS\system32\   I don't actually have a file called
> python25.zip, but I do have one called  python25.dll - so has something gone
> wrong in creation of sys.path?
> 
No. I'm not sure why the zip file is on there by default.

regards
  Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC              http://www.holdenweb.com/




More information about the Python-list mailing list