在 64 位 Windows 上安装安装工具
我在 Windows 7 64 位上运行 Python 2.7,当我运行 setuptools 的安装程序时,它告诉我尚未安装 Python 2.7。具体的错误消息是:
`Python Version 2.7 required which was not found in the registry`
我安装的 Python 版本是:
`Python 2.7 (r27:82525, Jul 4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)] on win32`
我正在查看 setuptools 站点,它没有提到任何 64 位 Windows 的安装程序。我错过了什么还是我必须从源代码安装它?
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:
`Python Version 2.7 required which was not found in the registry`
My installed version of Python is:
`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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(11)
问题:您有 64 位 Python 和 32 位安装程序。这会给扩展模块带来问题。
安装程序找不到 Python 的原因是 Windows 7 的透明 32 位模拟。64 位和 32 位程序将写入 Windows 注册表的不同部分。
64 位:
HKLM|HKCU\SOFTWARE\
32 位:
HKLM|HKCU\SOFTWARE\wow6432node\
。这意味着 64 位 Python 安装程序会写入
HKLM\SOFTWARE\Python
,但 32 位 setuptools 安装程序会查看HKLM\SOFTWARE\wow6432node\Python
(这是由 Windows 自动处理,程序不会注意到)。这是预期行为,而不是错误。通常,您有以下选择:
HKLM\SOFTWARE\Python
复制到HKLM\SOFTWARE\wow6432node\Python
,但这会导致问题二进制发行版,因为 64 位 Python 无法加载 32 位编译模块(不要这样做!)对于 setuptools 本身,例如,您可以'请勿使用 64 位 Python 的 32 位安装程序,因为它包含二进制文件。 但是有一个 64 位安装程序 http://www.lfd.uci .edu/~gohlke/pythonlibs/(也有许多其他模块的安装程序)。如今,PyPi 上的许多软件包都有二进制发行版,因此您可以通过 pip 安装它们。
Problem: you have 64-bit Python, and a 32-bit installer. This will cause problems for extension modules.
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.
64-bit:
HKLM|HKCU\SOFTWARE\
32-bit:
HKLM|HKCU\SOFTWARE\wow6432node\
.This means that the 64-bit Python installer writes to
HKLM\SOFTWARE\Python
, but the 32-bit setuptools installer looks atHKLM\SOFTWARE\wow6432node\Python
(this is handled by windows automatically, programs don't notice). This is expected behavior and not a bug.Usually, you have these choices:
HKLM\SOFTWARE\Python
toHKLM\SOFTWARE\wow6432node\Python
, but this will cause problems with binary distributions, as 64-bit Python can't load 32-bit compiled modules (do NOT do this!)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.
显然(在 OS X 上遇到了相关的 64 位和 32 位问题)Windows 安装程序中存在一个错误。我偶然发现了此解决方法,这可能会有所帮助 -基本上,您创建自己的注册表值
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.6\InstallPath
并从HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.6\InstallPath< 复制 InstallPath 值/代码>。请参阅下面的答案了解更多详细信息。
如果您这样做,请注意 setuptools可能只安装 32 位库。
注意:下面的回复提供了更多详细信息,因此也请阅读它们。
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\InstallPath
and copy over the InstallPath value fromHKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.6\InstallPath
. See the answer below for more details.If you do this, beware that setuptools may only install 32-bit libraries.
NOTE: the responses below offer more detail, so please read them too.
我制作了一个注册表 (.reg) 文件,它将自动为您更改注册表。如果安装在“C:\Python27”中,则可以使用:
下载 32 位版本
HKEY_LOCAL_MACHINE|HKEY_CURRENT_USER\SOFTWARE\wow6432node\
下载64位版本
HKEY_LOCAL_MACHINE|HKEY_CURRENT_USER\SOFTWARE\
I made a registry (.reg) file that will automatically change the registry for you. It works if it's installed in "C:\Python27":
Download 32-bit version
HKEY_LOCAL_MACHINE|HKEY_CURRENT_USER\SOFTWARE\wow6432node\
Download 64-bit version
HKEY_LOCAL_MACHINE|HKEY_CURRENT_USER\SOFTWARE\
是的,你是对的,问题出在 64 位 Python 和 32 位 setuptools 安装程序上。
在 Windows 上安装 64 位 setuptools 的最佳方法是将 ez_setup.py 下载到C:\Python27\Scripts 并运行它。它将下载适合 setuptools 的 64 位 .egg 文件并为您安装。
来源: http://pypi.python.org/pypi/setuptools
PS 我不建议这样做使用第 3 方 64 位 .exe setuptools 安装程序或操作注册表
Yes, you are correct, the issue is with 64-bit Python and 32-bit installer for setuptools.
The best way to get 64-bit setuptools installed on Windows is to download ez_setup.py to C:\Python27\Scripts and run it. It will download appropriate 64-bit .egg file for setuptools and install it for you.
Source: http://pypi.python.org/pypi/setuptools
P.S. I'd recommend against using 3rd party 64-bit .exe setuptools installers or manipulating registry
创建一个名为
python2.7.reg
(注册表文件)的文件并将以下内容放入其中:并确保每个路径都正确!
然后运行(合并)它并完成:)
Create a file named
python2.7.reg
(registry file) and put this content into it:And make sure every path is right!
Then run (merge) it and done :)
从此要点获取文件
register.py
。将其保存到C盘或D盘,进入CMD运行它:然后就可以安装它了。
Get the file
register.py
from this gist. Save it on your C drive or D drive, go to CMD to run it with:Then you will be able to install it.
对于 Windows 上的 64 位 Python,下载 ez_setup.py 并运行它;它将下载适当的 .egg 文件并为您安装。
在撰写本文时,由于 distutils 安装程序兼容性,.exe 安装程序不支持适用于 Windows 的 64 位版本的 Python问题。
For 64-bit Python on Windows download ez_setup.py and run it; it will download the appropriate .egg file and install it for you.
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.
要允许 Windows 安装程序在 Windows 7 中查找已安装的 Python 目录,或者更改要安装安装程序的 Python 安装,请将安装路径添加到 InstallPath 注册表项中(默认)值:
其中“X”是 Python 版本(即 2.5、2.6 或 2.7)。
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 InstallPath registry key's (Default) value:
Where "X" is the Python version (that is, 2.5, 2.6, or 2.7).
我尝试了上述方法,并将注册表项添加到 LOCALMACHINE 中并没有完成工作。因此,如果您仍然陷入困境,请尝试此操作。
将上述内容复制粘贴到记事本中并将其另存为 Python27.reg 。现在按照上面答案中提到的方式运行/合并文件。 (确保 Python 安装的路径根据您的安装进行更正。
它只是对当前用户执行上述答案针对本地计算机的建议。
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.
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.
It simply does ,what the above answers suggest for a local machine ,to the current user.
这是另一个帖子/线程的链接。我能够运行这个脚本来自动注册 Python 2.7。 (确保从要注册的 Python 2.x
.exe
运行它!)要注册 Python 3.x,我必须修改
print
语法并导入 < code>winreg(而不是_winreg
),然后运行 Python 3.exe
。https://stackoverflow.com/a/29633714/3568893
Here is a link to another post/thread. I was able run this script to automate registration of Python 2.7. (Make sure to run it from the Python 2.x
.exe
you want to register!)To register Python 3.x I had to modify the
print
syntax and importwinreg
(instead of_winreg
), then run the Python 3.exe
.https://stackoverflow.com/a/29633714/3568893
您可以在这里找到许多库的 64 位安装程序:http://www.lfd.uci .edu/~gohlke/pythonlibs/
You can find 64bit installers for a lot of libs here: http://www.lfd.uci.edu/~gohlke/pythonlibs/