"Python version 2.7 required, which was not found in the registry" error when attempting to install netCDF4 on Windows 8

134,945

Solution 1

Just download Python 2.7.6 Windows Installer from the official Python download page, and launch the install package.

Solution 2

This error can occur if you are installing a package with a different bitness than your Python version. To see whether your Python installation is 32- or 64-bit, see here.

Some superpacks (e.g. for Scipy) available on SourceForge or python.org are for 32-bit systems and some are for 64-bit systems. See this answer. In Windows, uninstalling the 32-bit and installing the 64-bit version (or vice versa if your installation is 32-bit) can solve the problem.

Solution 3

I had the same issue when using an .exe to install a Python package (because I use Anaconda and it didn't add Python to the registry). I fixed the problem by running this script:

#
# script to register Python 2.0 or later for use with 
# Python extensions that require Python registry settings
#
# written by Joakim Loew for Secret Labs AB / PythonWare
#
# source:
# http://www.pythonware.com/products/works/articles/regpy20.htm
#
# modified by Valentine Gogichashvili as described in http://www.mail-archive.com/[email protected]/msg10512.html

import sys

from _winreg import *

# tweak as necessary
version = sys.version[:3]
installpath = sys.prefix

regpath = "SOFTWARE\\Python\\Pythoncore\\%s\\" % (version)
installkey = "InstallPath"
pythonkey = "PythonPath"
pythonpath = "%s;%s\\Lib\\;%s\\DLLs\\" % (
    installpath, installpath, installpath
)

def RegisterPy():
    try:
        reg = OpenKey(HKEY_CURRENT_USER, regpath)
    except EnvironmentError as e:
        try:
            reg = CreateKey(HKEY_CURRENT_USER, regpath)
            SetValue(reg, installkey, REG_SZ, installpath)
            SetValue(reg, pythonkey, REG_SZ, pythonpath)
            CloseKey(reg)
        except:
            print "*** Unable to register!"
            return
        print "--- Python", version, "is now registered!"
        return
    if (QueryValue(reg, installkey) == installpath and
        QueryValue(reg, pythonkey) == pythonpath):
        CloseKey(reg)
        print "=== Python", version, "is already registered!"
        return
    CloseKey(reg)
    print "*** Unable to register!"
    print "*** You probably have another Python installation!"

if __name__ == "__main__":
    RegisterPy()

Solution 4

Try the steps described here: http://avaminzhang.wordpress.com/2011/11/24/python-version-2-7-required-which-was-not-found-in-the-registry/

Solution 5

I think it really depends on why this error is given. It may be the bitness issue, but it may also be because of a deinstaller bug that leaves registry entries behind.

I just had this case because I need two versions of Python on my system. When I tried to install SCons (using Python2), the .msi installer failed, saying it only found Python3 in the registry. So I uninstalled it, with the result that no Python was found at all. Frustrating! (workaround: install SCons with pip install --egg --upgrade scons)

Anyway, I'm sure there are threads on that phenomenon. I just thought it would fit here because this was one of my top search results.

Share:
134,945
bogdan
Author by

bogdan

Student.

Updated on July 09, 2022

Comments

  • bogdan
    bogdan almost 2 years

    I use Anaconda 1.7, 32 bit. I downloaded the correct version of the netCDF4 installer from here.

    I attempted to copy the HKEY_LOCAL_MACHINE\SOFTWARE\Python folder into HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node. No luck.

    Does anyone have any idea why this might be happening? Anaconda installed in the default location, C:/.

    Yes, I know Anaconda has netCDF4 in the packages list - but if you look closely, it's only offered for Mac and Linux.

  • Brent
    Brent almost 10 years
    Thanks, I had Python 2.6.5(x64)and PSUTIL for 2.6 is only available in x86. I just had to switch my Python version to x86
  • Sir Jane
    Sir Jane over 8 years
    That's not too helpful. The same error may still occur, e.g. if you want to install two versions of Python, and then the Windows installer fails just the same. I think it would really be better to look at what the reason is here.
  • pepr
    pepr over 8 years
    @SirJane: I cannot confirm that. I usually have at least the last Python 2, and the last Python 3 side-by-side. Besides the Python 2.7 and 3.5, I often have Python 2.x or Python 3.x with different subversions for trying some features of some packages or trying to solve the problem of others. Having all the versions installed at the same time, I never had problems like that with official distributions of Python for Windows.
  • pepr
    pepr over 8 years
    @SirJane: I agree it could be 32 vs. 64-bit difference. The link goes to 32-bit version of Python that should work.
  • Sir Jane
    Sir Jane over 8 years
    True, for this case your suggestion should work. But this error can also arise when you install 3.x before 2.x, and then the installer doesn't solve the problem, see my little answer below.
  • Snake Sanders
    Snake Sanders over 7 years
    In my case I was trying to install amd64 package on win32 python, your comment opened my eyes
  • Motassem Kassab
    Motassem Kassab over 7 years
    you shall be named "The Oracle"
  • mnut
    mnut almost 7 years
    For python 3, just add parentheses around the print calls, and replace import _winreg by import winreg and it works perfectly
  • Apostolos
    Apostolos over 4 years
    OK @duahime, but automatic (programmatically) operations on the Registry are not safe at all. That's why people ALWAYS suggest manual solutions. So, can you please also write how to do all that manually, in just 2-3 lines (which is usually all that it takes)?
  • Bruno
    Bruno over 3 years
    God bless you. Thanks