Python 在 64 位 Windows 上安装 SetupTools
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3652625/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Installing SetupTools on 64-bit Windows
提问by quanticle
I'm running Python 2.7 on Windows 7 64-bit, and when I run the installer for setuptools it tells me that Python 2.7 is not installed. The specific error message is:
我在 64 位 Windows 7 上运行 Python 2.7,当我运行 setuptools 的安装程序时,它告诉我未安装 Python 2.7。具体的错误信息是:
`Python Version 2.7 required which was not found in the registry`
My installed version of Python is:
我安装的 Python 版本是:
`Python 2.7 (r27:82525, Jul 4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)] on win32`
I'm looking at the setuptools site and it doesn't mention any installers for 64-bit Windows. Have I missed something or do I have to install this from source?
我正在查看 setuptools 站点,它没有提到任何 64 位 Windows 的安装程序。我错过了什么还是我必须从源代码安装它?
采纳答案by Dave Everitt
Apparently (having faced related 64- and 32-bit issues on OS X) there is a bug in the Windows installer. I stumbled across this workaround, which might help - basically, you create your own registry value HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.6\InstallPathand copy over the InstallPath value from HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.6\InstallPath. See the answer below for more details.
显然(在 OS X 上遇到了相关的 64 位和 32 位问题)Windows 安装程序中存在一个错误。我偶然发现了这个解决方法,这可能会有所帮助 - 基本上,您创建自己的注册表值HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.6\InstallPath并从HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.6\InstallPath. 有关更多详细信息,请参阅下面的答案。
If you do this, beware that setuptools may only install 32-bit libraries.
如果您这样做,请注意 setuptools可能只安装 32 位库。
NOTE: the responses below offer more detail, so please read them too.
注意:下面的回复提供了更多细节,所以也请阅读它们。
回答by leoluk
Problem: you have 64-bit Python, and a 32-bit installer. This will cause problems for extension modules.
问题:您有 64 位 Python 和 32 位安装程序。这会导致扩展模块出现问题。
The reasons why the installer doesn't finds Python is the transparent 32-bit emulation from Windows 7. 64-bit and 32-bit programs will write to different parts of the Windows registry.
安装程序找不到 Python 的原因是 Windows 7 的透明 32 位模拟。64 位和 32 位程序将写入 Windows 注册表的不同部分。
64-bit: HKLM|HKCU\SOFTWARE\
64 位: HKLM|HKCU\SOFTWARE\
32-bit: HKLM|HKCU\SOFTWARE\wow6432node\.
32 位:HKLM|HKCU\SOFTWARE\wow6432node\.
This means that the 64-bit Python installer writes to HKLM\SOFTWARE\Python, but the 32-bit setuptools installer looks at HKLM\SOFTWARE\wow6432node\Python(this is handled by windows automatically, programs don't notice). This is expected behavior and not a bug.
这意味着 64 位 Python 安装程序写入HKLM\SOFTWARE\Python,但 32 位 setuptools 安装程序查看HKLM\SOFTWARE\wow6432node\Python(这是由 windows 自动处理的,程序不会注意到)。这是预期的行为,而不是错误。
Usually, you have these choices:
通常,您有以下选择:
- the "clean" way: use 32-bit Python if you have to use 32-bit modules or extensions
- the other "clean" way: only use 64-bit installers when using 64-bit Python (see below)
- what the answer above suggests: copy
HKLM\SOFTWARE\PythontoHKLM\SOFTWARE\wow6432node\Python, but this willcause problems with binary distributions, as 64-bit Python can't load 32-bit compiled modules (do NOT do this!) - install pure Python modules with setuptools instead of the distutils installer (easy_install or pip)
- “干净”的方式:如果必须使用 32 位模块或扩展,请使用 32 位 Python
- 另一种“干净”的方式:在使用 64 位 Python 时只使用 64 位安装程序(见下文)
- 上面的答案暗示了什么:复制
HKLM\SOFTWARE\Python到HKLM\SOFTWARE\wow6432node\Python,但这会导致二进制发行版出现问题,因为 64 位 Python 无法加载 32 位编译模块(不要这样做!) - 使用 setuptools 而不是 distutils 安装程序(easy_install 或 pip)安装纯 Python 模块
For setuptools itself, for example, you can't use a 32-bit installer for 64-bit Python as it includes binary files. But there's a 64-bit installer at http://www.lfd.uci.edu/~gohlke/pythonlibs/(has many installers for other modules too). Nowadays, many packages on PyPi have binary distributions, so you can install them via pip.
例如,对于 setuptools 本身,您不能为 64 位 Python 使用 32 位安装程序,因为它包含二进制文件。但是http://www.lfd.uci.edu/~gohlke/pythonlibs/ 上有一个 64 位安装程序(也有许多其他模块的安装程序)。现在,PyPi 上的许多软件包都有二进制发行版,因此您可以通过 pip 安装它们。
回答by Constantin
For 64-bit Python on Windows download ez_setup.pyand run it; it will download the appropriate .egg file and install it for you.
对于 Windows 上的 64 位 Python,下载ez_setup.py并运行它;它将下载适当的 .egg 文件并为您安装。
At the time of writing the .exe installer does not support 64-bit versions of Python for Windows, due to a distutils installer compatibility issue.
在撰写本文时,由于distutils 安装程序兼容性问题,.exe 安装程序不支持 64 位版本的 Python for Windows 。
回答by Joe DF
I made a registry (.reg) file that will automatically change the registry for you. It works if it's installed in "C:\Python27":
我制作了一个注册表 (.reg) 文件,它将自动为您更改注册表。如果它安装在“C:\Python27”中,它就可以工作:
Download 32-bit versionHKEY_LOCAL_MACHINE|HKEY_CURRENT_USER\SOFTWARE\wow6432node\
下载 32 位版本HKEY_LOCAL_MACHINE|HKEY_CURRENT_USER\SOFTWARE\wow6432node\
Download 64-bit versionHKEY_LOCAL_MACHINE|HKEY_CURRENT_USER\SOFTWARE\
下载 64 位版本HKEY_LOCAL_MACHINE|HKEY_CURRENT_USER\SOFTWARE\
回答by monkut
To allow Windows installers to find the installed Python directory in Windows 7, OR, change which Python installation to install an installer into, add the installed path into the InstallPathregistry key's (Default)value:
要允许 Windows 安装程序在Windows 7 中找到已安装的 Python 目录,或者更改要将安装程序安装到的 Python 安装,请将安装路径添加到InstallPath注册表项的(默认)值中:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.X\InstallPath
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.X\InstallPath
Where "X" is the Python version (that is, 2.5, 2.6, or 2.7).
其中“ X”是 Python 版本(即 2.5、2.6 或 2.7)。
回答by Richard Hermanson
You can find 64bit installers for a lot of libs here: http://www.lfd.uci.edu/~gohlke/pythonlibs/
您可以在此处找到许多库的 64 位安装程序:http: //www.lfd.uci.edu/~gohlke/pythonlibs/
回答by arainchi
Yes, you are correct, the issue is with 64-bit Python and 32-bit installer for setuptools.
是的,您是对的,问题在于 64 位 Python 和 32 位安装程序的 setuptools。
The best way to get 64-bit setuptools installed on Windows is to download ez_setup.pyto C:\Python27\Scripts and run it. It will download appropriate 64-bit .egg file for setuptools and install it for you.
在 Windows 上安装 64 位 setuptools 的最佳方法是将ez_setup.py下载到 C:\Python27\Scripts 并运行它。它将为 setuptools 下载适当的 64 位 .egg 文件并为您安装。
Source: http://pypi.python.org/pypi/setuptools
来源:http: //pypi.python.org/pypi/setuptools
P.S. I'd recommend against using 3rd party 64-bit .exe setuptools installers or manipulating registry
PS 我建议不要使用 3rd 方 64 位 .exe setuptools 安装程序或操作注册表
回答by MichaelvdNet
Create a file named python2.7.reg(registry file) and put this content into it:
创建一个名为python2.7.reg(注册表文件)的文件,并将内容放入其中:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore.7]
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore.7\Help]
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore.7\Help\MainPythonDocumentation]
@="C:\Python27\Doc\python26.chm"
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore.7\InstallPath]
@="C:\Python27\"
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore.7\InstallPath\InstallGroup]
@="Python 2.7"
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore.7\Modules]
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore.7\PythonPath]
@="C:\Python27\Lib;C:\Python27\DLLs;C:\Python27\Lib\lib-tk"
And make sure every path is right!
并确保每条路径都是正确的!
Then run (merge) it and done :)
然后运行(合并)它并完成:)
回答by nickleefly
回答by Shaswat Rungta
I tried the above and adding the registry keys to the LOCALMACHINE was not getting the job done. So in case you are still stuck , try this.
我尝试了上述操作,但将注册表项添加到 LOCALMACHINE 并没有完成工作。所以如果你仍然被卡住,试试这个。
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\SOFTWARE\Python]
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore]
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\2.7]
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\2.7\Help]
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\2.7\Help\Main Python Documentation] @="C:\Python27\Doc\python272.chm"
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\2.7\InstallPath] @="C:\Python27\"
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\2.7\InstallPath\InstallGroup] @="Python 2.7"
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\2.7\Modules]
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\2.7\PythonPath] @="C:\Python27\Lib;C:\Python27\DLLs;C:\Python27\Lib\lib-tk"
Windows 注册表编辑器 5.00 版
[HKEY_CURRENT_USER\SOFTWARE\Python]
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore]
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\2.7]
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\2.7\Help]
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\2.7\Help\Main Python Documentation] @="C:\Python27\Doc\python272.chm"
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\2.7\InstallPath] @="C:\Python27\"
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\2.7\InstallPath\InstallGroup] @="Python 2.7"
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\2.7\Modules]
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\2.7\PythonPath] @="C:\Python27\Lib;C:\Python27\DLLs;C:\Python27\Lib\lib-tk"
Copy paste the above in notepad and save it as Python27.reg . Now run/merge the file as mentioned in the answers above. (Make sure the paths of Python installation are corrected as per your installation.
将上述内容复制粘贴到记事本中并将其另存为 Python27.reg 。现在运行/合并文件,如上述答案中所述。(确保根据您的安装更正 Python 安装路径。
It simply does ,what the above answers suggest for a local machine ,to the current user.
它只是对当前用户执行上述答案对本地机器的建议。

