I recently upgraded my Python 2.7.1 installation to 2.7.2 using the .msi
insta开发者_如何转开发ller and the process seemed to go OK. However afterwards I happened to be looking at what the default values were for sys.path
and noticed the entry for 'C:\Windows\system32\python27.zip'. Wondering exactly what was in it, I decided to try opening it with a Zip utility to check out its contents — however I soon discovered that the file wasn't there (although there is a python27.dll
).
Anyhow I'm now wondering if something is wrong. Several existing Python programs I frequently use all seem to work without problems, so I'm not sure whether the installation is messed up or not (or how to fix it, if it is).
Update
I'm aware of and have read PEP273, so know about .zip file modules. That's not what I'm asking about. What I want to know is the fact that there is no python27.zip
installed on my system even though it's referred to in my sys.path
a problem? I've never encountered problems importing standard Python libraries, which is what I would expect not having one would affect.
From PEP 273 -- Import Modules from Zip Archives:
Just as sys.path currently has default directory names, a default zip archive name is added too. Otherwise there is no way to import all Python library files from an archive.
...
The problem is what the name should be. The name should be linked with the Python version, so the Python executable can correctly find its corresponding libraries even when there are multiple Python versions on the same machine.
We add one name to sys.path. On Unix, the directory is sys.prefix + "/lib", and the file name is "python%s%s.zip" % (sys.version[0], sys.version[2]). So for Python 2.2 and prefix /usr/local, the path /usr/local/lib/python2.2/ is already on sys.path, and /usr/local/lib/python22.zip would be added. On Windows, the file is the full path to python22.dll, with "dll" replaced by "zip". The zip archive name is always inserted as the second item in sys.path. The first is the directory of the main.py (thanks Tim).
精彩评论