问题:在64位Windows上安装SetupTools

我在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?


回答 0

显然(在OS X上面临相关的64位和32位问题),Windows安装程序中存在一个错误。我偶然发现了这种解决方法,它可能会有所帮助-基本上,您可以创建自己的注册表值,HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.6\InstallPath然后从中复制InstallPath值HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.6\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.


回答 1

问题:您有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\PythonHKLM\SOFTWARE\wow6432node\Python,但这导致二进制分发出现问题,因为64位Python无法加载32位编译模块(请勿这样做!)
  • 使用setuptools而不是distutils安装程序(easy_install或pip)安装纯Python模块

例如,对于setuptools本身,您不能将32位安装程序用于64位Python,因为它包含二进制文件。但是在http://www.lfd.uci.edu/~gohlke/pythonlibs/中有一个64位安装程序(其他模块也有许多安装程序)。如今,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.


回答 2

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


回答 3

是的,您是对的,问题出在setuptools的64位Python和32位安装程序上。

在Windows上安装64位setuptools的最佳方法是将ez_setup.py下载到C:\ Python27 \ Scripts并运行它。它将下载用于setuptools的适当的64位.egg文件并为您安装。

资料来源:http : //pypi.python.org/pypi/setuptools

PS我建议您不要使用第三方的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


回答 4

创建一个名为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 :)


回答 5

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.


回答 6

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


回答 7

要允许Windows安装程序在Windows 7Windows 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).


回答 8

我尝试了上述操作,但将注册表项添加到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 \ Main 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.


回答 9

这是另一个帖子/主题的链接。我能够运行此脚本来自动注册python 2.7。(确保从.exe要注册的Python 2.x运行它!)

要注册Python 3.x,我必须修改print语法并导入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


回答 10

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


声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。