尝试在 Windows 8 上安装 netCDF4 时出现“需要 Python 版本 2.7,未在注册表中找到”错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19169582/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 13:03:05  来源:igfitidea点击:

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

pythonwindowspython-2.7installpackage

提问by bogdan

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

我使用 Anaconda 1.7,32 位。我从这里下载了正确版本的 netCDF4 安装程序。

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

我试图将 HKEY_LOCAL_MACHINE\SOFTWARE\Python 文件夹复制到 HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node 中。没运气。

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

有谁知道为什么会发生这种情况?Anaconda 安装在默认位置,C:/。

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

是的,我知道 Anaconda 在包列表中有 netCDF4 - 但如果你仔细观察,它只提供给 Mac 和 Linux。

采纳答案by pepr

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

只要下载的Python 2.7.6的Windows安装程序Python的官方下载页面,并启动安装包。

回答by user

I had such problem. Solution was simple :

我有这样的问题。解决方案很简单:

  1. Install python 2.7 64bit version.
  2. Export HKEY_LOCAL_MACHINE\SOFTWARE\Python.
  3. Remove Python 2.7.
  4. insert exported reg file.
  5. rename all C:\Python27 to C:\Anaconda ( insert your path ).
  1. 安装python 2.7 64位版本。
  2. 导出 HKEY_LOCAL_MACHINE\SOFTWARE\Python。
  3. 删除 Python 2.7。
  4. 插入导出的reg文件。
  5. 将所有 C:\Python27 重命名为 C:\Anaconda(插入您的路径)。

P.S. Sorry, for bad grammar.

PS对不起,语法不好。

回答by 1''

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.

如果您安装的包的位数与 Python 版本不同,则可能会发生此错误。要查看您的 Python 安装是 32 位还是 64 位,请参见此处

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.

SourceForge 或 python.org 上提供的一些超级包(例如用于 Scipy)适用于 32 位系统,有些适用于 64 位系统。看到这个答案。在 Windows 中,卸载 32 位并安装 64 位版本(如果您安装的是 32 位,则反之亦然)可以解决问题。

回答by duhaime

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:

我在使用 .exe 安装 Python 包时遇到了同样的问题(因为我使用 Anaconda 并且它没有将 Python 添加到注册表中)。我通过运行这个脚本解决了这个问题:

#
# 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()

回答by Sir Jane

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

我刚刚遇到了这个案例,因为我的系统上需要两个版本的 Python。当我尝试安装 SCons(使用 Python2)时,.msi 安装程序失败,说它只在注册表中找到 Python3。所以我卸载了它,结果根本找不到Python。令人沮丧!(解决方法:使用 安装 SCons 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.

无论如何,我确信有关于这种现象的线索。我只是认为它适合这里,因为这是我的热门搜索结果之一。

回答by ADITYA RATHI

Check for the 32/64 bit you trying to install. both python interpreter and your app which trying to use python might be of different bit.

检查您尝试安装的 32/64 位。python解释器和您尝试使用python的应用程序可能有所不同。