Installing SetupTools on 64-bit Windows

Question:

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?

Asked By: quanticle

||

Answers:

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_MACHINESOFTWAREWow6432NodePythonPythonCore2.6InstallPath and copy over the InstallPath value from HKEY_LOCAL_MACHINESOFTWAREPythonPythonCore2.6InstallPath. 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.

Answered By: Dave Everitt

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|HKCUSOFTWARE

32-bit: HKLM|HKCUSOFTWAREwow6432node.

This means that the 64-bit Python installer writes to HKLMSOFTWAREPython, but the 32-bit setuptools installer looks at HKLMSOFTWAREwow6432nodePython (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 HKLMSOFTWAREPython to HKLMSOFTWAREwow6432nodePython, 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.

Answered By: leoluk

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.

Answered By: Constantin

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_USERSOFTWAREwow6432node

Download 64-bit version HKEY_LOCAL_MACHINE|HKEY_CURRENT_USERSOFTWARE

Answered By: Joe DF

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_MACHINESOFTWAREWow6432NodePythonPythonCore2.XInstallPath

Where “X” is the Python version (that is, 2.5, 2.6, or 2.7).

Answered By: monkut

You can find 64bit installers for a lot of libs here: http://www.lfd.uci.edu/~gohlke/pythonlibs/

Answered By: Richard Hermanson

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:Python27Scripts 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

Answered By: arainchi

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

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINESOFTWAREWow6432NodePythonPythonCore2.7]

[HKEY_LOCAL_MACHINESOFTWAREWow6432NodePythonPythonCore2.7Help]

[HKEY_LOCAL_MACHINESOFTWAREWow6432NodePythonPythonCore2.7HelpMainPythonDocumentation]
@="C:\Python27\Doc\python26.chm"

[HKEY_LOCAL_MACHINESOFTWAREWow6432NodePythonPythonCore2.7InstallPath]
@="C:\Python27\"

[HKEY_LOCAL_MACHINESOFTWAREWow6432NodePythonPythonCore2.7InstallPathInstallGroup]
@="Python 2.7"

[HKEY_LOCAL_MACHINESOFTWAREWow6432NodePythonPythonCore2.7Modules]

[HKEY_LOCAL_MACHINESOFTWAREWow6432NodePythonPythonCore2.7PythonPath]
@="C:\Python27\Lib;C:\Python27\DLLs;C:\Python27\Lib\lib-tk"

And make sure every path is right!

Then run (merge) it and done 🙂

Answered By: MichaelvdNet

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.

Answered By: nickleefly

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_USERSOFTWAREPython]

[HKEY_CURRENT_USERSOFTWAREPythonPythonCore]

[HKEY_CURRENT_USERSOFTWAREPythonPythonCore2.7]

[HKEY_CURRENT_USERSOFTWAREPythonPythonCore2.7Help]

[HKEY_CURRENT_USERSOFTWAREPythonPythonCore2.7HelpMain Python Documentation]
@=”C:Python27Docpython272.chm”

[HKEY_CURRENT_USERSOFTWAREPythonPythonCore2.7InstallPath]
@=”C:Python27″

[HKEY_CURRENT_USERSOFTWAREPythonPythonCore2.7InstallPathInstallGroup]
@=”Python 2.7″

[HKEY_CURRENT_USERSOFTWAREPythonPythonCore2.7Modules]

[HKEY_CURRENT_USERSOFTWAREPythonPythonCore2.7PythonPath]
@=”C:Python27Lib;C:Python27DLLs;C:Python27Liblib-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.

Answered By: Shaswat Rungta

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

Answered By: robertberrington
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.