133

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?

3
  • 7
    Note to readers: Scroll down, the accepted answer isn't the best one.
    – user334911
    May 20, 2013 at 16:12
  • Unfortunately, the 64-bit SetupTools installer didn't exist when I posted my question, so I accepted the workaround, knowing full-well that it's a hack.
    – quanticle
    May 26, 2013 at 4:22
  • 2
    @JohnRobertson what is the best answer then?
    – rrs
    Jan 14, 2014 at 16:18

11 Answers 11

142

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.

4
  • 2
    Same goes for the other way around (2.7 32 and setuptools 64) stackoverflow.com/a/10966396/404385 <-- to find out what's your installed python ver and 32/64
    – Cu7l4ss
    May 19, 2013 at 8:31
  • This is not really Python's fault, I think
    – leoluk
    Sep 6, 2013 at 12:11
  • 1
    For those who do not know how to install a whl file, you install them using pip, like pip install xyz.whl
    – arun
    Oct 8, 2015 at 1:30
  • I'm afraid your link has died again.
    – Ryan M
    Aug 12 at 10:37
91

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
  • 1
    Works with installing PIL (PIL-1.1.7.win32-py2.7) also.
    – panny
    Oct 12, 2013 at 9:42
69

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\

6
  • 3
    Your REG file worked for me but I had the opposite problem so I had to remove the "\Wow6432Node" from all the key names.
    – pwhe23
    Oct 31, 2012 at 3:27
  • I guess I could post a link for 32bit.. :P
    – Joe DF
    Oct 31, 2012 at 10:55
  • Awesome patch files! Great! Thank you for that!!
    – Benny Code
    Nov 1, 2014 at 21:54
  • Still relevant 3 years later. Thank you sir.
    – twig
    Apr 3, 2015 at 6:16
  • So the 32 or 64 bits is for the version of python, not the OS bits, right? Apr 17, 2016 at 2:02
28

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

2
  • 2
    can't believe how fast and easy this solution was. I spent hours stuck on other avenues.
    – Brett
    Mar 2, 2013 at 22:06
  • 1
    Best and safest solution in my opinion!
    – djfranzwa
    Aug 29, 2014 at 10:46
9

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

1
  • Thanks! I can confirm it works for python 2.76 and h5py setup. Maybe just update the doc path to python276.chm for the good order :)
    – mork
    Apr 10, 2014 at 17:52
9

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.

1
  • This is the simplest solution. Thanks! I encountered this problem when try to install wxPython2.8-win32-unicode-2.8.12.1-py27 and it allways complains to python not registered
    – Robert1968
    Jul 20, 2017 at 14:54
3

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.

1
  • this one actually worked for me! the other script by Joe DF didn't work for me Apr 17, 2016 at 1:56
1

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

0
1

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.

0

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

-2

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

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.