在 64 位 Windows 上安装安装工具

发布于 2024-09-18 07:22:51 字数 394 浏览 6 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

太阳男子 2024-09-25 07:22:51

问题:您有 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 自动处理,程序不会注意到)。这是预期行为,而不是错误。

通常,您有以下选择:

  • “干净”方式:如果必须使用 32 位模块或扩展,则使用 32 位 Python
  • 另一种“干净”方式:在使用 64 位 Python 时仅使用 64 位安装程序(请参阅下面)
  • 上面的答案建议的内容:将 HKLM\SOFTWARE\Python 复制到 HKLM\SOFTWARE\wow6432node\Python,但这导致问题二进制发行版,因为 64 位 Python 无法加载 32 位编译模块(不要这样做!)
  • 使用 setuptools 而不是 distutils 安装程序(easy_install 或 pip)安装纯 Python 模块

对于 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 at HKLM\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:

  • 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\Python to HKLM\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!)
  • install pure Python modules with setuptools instead of the distutils installer (easy_install or pip)

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.

柳若烟 2024-09-25 07:22:51

显然(在 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 from HKEY_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.

萌逼全场 2024-09-25 07:22:51

我制作了一个注册表 (.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\

童话 2024-09-25 07:22:51

是的,你是对的,问题出在 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

微暖i 2024-09-25 07:22:51

创建一个名为python2.7.reg(注册表文件)的文件并将以下内容放入其中:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.7]

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.7\Help]

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.7\Help\MainPythonDocumentation]
@="C:\\Python27\\Doc\\python26.chm"

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.7\InstallPath]
@="C:\\Python27\\"

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.7\InstallPath\InstallGroup]
@="Python 2.7"

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.7\Modules]

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.7\PythonPath]
@="C:\\Python27\\Lib;C:\\Python27\\DLLs;C:\\Python27\\Lib\\lib-tk"

并确保每个路径都正确!

然后运行(合并)它并完成:)

Create a file named python2.7.reg (registry file) and put this content into it:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.7]

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.7\Help]

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.7\Help\MainPythonDocumentation]
@="C:\\Python27\\Doc\\python26.chm"

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.7\InstallPath]
@="C:\\Python27\\"

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.7\InstallPath\InstallGroup]
@="Python 2.7"

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.7\Modules]

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.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 :)

何其悲哀 2024-09-25 07:22:51

此要点获取文件register.py。将其保存到C盘或D盘,进入CMD运行它:

'python register.py'

然后就可以安装它了。

Get the file register.py from this gist. Save it on your C drive or D drive, go to CMD to run it with:

'python register.py'

Then you will be able to install it.

傾城如夢未必闌珊 2024-09-25 07:22:51

对于 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.

深居我梦 2024-09-25 07:22:51

要允许 Windows 安装程序在 Windows 7 中查找已安装的 Python 目录,或者更改要安装安装程序的 Python 安装,请将安装路径添加到 InstallPath 注册表项中(默认)值:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.X\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:

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).

任谁 2024-09-25 07:22:51

我尝试了上述方法,并将注册表项添加到 LOCALMACHINE 中并没有完成工作。因此,如果您仍然陷入困境,请尝试此操作。

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\主要 Python 文档]
@="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”

将上述内容复制粘贴到记事本中并将其另存为 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.

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"

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.

一口甜 2024-09-25 07:22:51

这是另一个帖子/线程的链接。我能够运行这个脚本来自动注册 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 import winreg (instead of _winreg), then run the Python 3 .exe.

https://stackoverflow.com/a/29633714/3568893

天生の放荡 2024-09-25 07:22:51

您可以在这里找到许多库的 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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文