Sys.path entries

Alan Harris-Reid aharrisreid at googlemail.com
Thu Dec 31 08:01:22 EST 2009


Gabriel Genellina wrote:
> <div class="moz-text-flowed">En Thu, 31 Dec 2009 04:31:06 -0300, Marco 
> Salden <marco.salden at gmail.com> escribió:
>
>> On Dec 30, 8:13 pm, Alan Harris-Reid <a... at baselinedata.co.uk> wrote:
>>> Hi there,
>>>
>>> In my sys.path (interpreter only, no application loaded), I have the
>>> following strange entries...
>>> 'C:\\WINDOWS\\system32\\python31.zip'.  This file does not exist
>>> anywhere (although python31.dll does exist in \windows\system32\), 
>>> where
>>> could it have come from?
>>> 'C:\\program files\\python31\\lib\\plat-win'.  There is no such
>>> directory, although I can see that this has been added by the 
>>> PYTHONPATH
>>> varible in PyConfig.h (when is this loaded?)
>>>
>>> Is there any way of removing these entries, or are they best left where
>>> they are?  (I am using Python 3.1 on WinXP)
>>>
>>
>> Same for me: C:\Windows\system32\python25.zip is in the only non-"C:
>> \Python25" directroy&file in my sys.path (under Python 2.5).
>> No idea why it needs it. And also in my case the zip file isnt in that
>> location anyway. So also not 3K only or so.
>> But I have no issues with it (so far :-)), do you? Do you run into
>> problems because of this in the path?
>
> Don't worry. The pythonNN.zip entry in sys.path is required to allow a 
> complete Python install to reside in a .zip file -- all modules used 
> at start time (os, ntpath, site...) must be importable before user 
> code has a chance of altering the import mechanisms. Tools like py2exe 
> may take advantage of that. See PEP 273: 
> http://www.python.org/dev/peps/pep-0273/
> Normally, such zip file doesn't exist, and Python just ignores its 
> sys.path entry; look at sys.path_importer_cache:
>
> py> sys.path_importer_cache
> ...
>  'C:\\WINDOWS\\system32\\python26.zip': <imp.NullImporter object at 
> 0x00AB0028>,
>  'd:\\apps\\python26\\lib\\plat-win': <imp.NullImporter object at 
> 0x00AB0480>,
>  'd:\\apps\\python26\\lib\\site-packages': None,
> ...
>
> Same for the plat-win directory; someone *could* use it for 
> Windows-specific stuff, but it doesn't exist by default and is simply 
> ignored.
>
>>> Also, regarding PyConfig.h - is this read every time I start 
>>> Python.exe?
>
> No. It's a copy of the .h file used when Python was compiled from its 
> C sources. distutils may read it to gather some information. Unless 
> you compile the interpreter from source yourself, it serves no other 
> purpose than document the options originally used to compile it.
>
Thanks for the reply Gabriel.  All useful stuff to store in my 
(ever-fading) brain.

Regards
Alan



More information about the Python-list mailing list