安装第三方库出现 Python version 2.7 required, which was not found in the registry

转载 2012年10月26日 22:37:05

安装第三方库出现 Python version 2.7 required, which was not found in the registry

建立一个文件 register.py 内容如下. 然后执行该脚本.

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


相关文章推荐

Python version 2.7 required, which was not found 注册表问题解决方法

最近在windows下用exe文件安装python中的numpy,scipy等模块时经常会发现跳出以上的问题,解决方法网上有很多,可行的并不多。 这里我采取直接修改注册表键值的方法: ...
  • pppii
  • pppii
  • 2015年09月23日 13:59
  • 5291

解决安装MySQL-python出现的:Python version 2.7 required, which was not found in the registry

安装MySQL-python-1.2.3.win-amd64-py2.7.exe,时提示:Python version 2.7 required, which was not found in the...

Delphi7高级应用开发随书源码

  • 2003年04月30日 00:00
  • 676KB
  • 下载

安装 MySQLdb 出现 Python version 2.7 required, which was not found in the registry

最近在学习python,然后在学到python操作数据库的时候出了些问题:安装 MySQLdb 出现 Python version 2.7 required, which was not found ...

Python Version 2.7 required which was not found in the registry

在使用“MySQLdb”操作MySQL数据库时,提示错误:ERR import MySQLdb ImportError: No module named MySQLdb,然后去下载安装包“MySQL-...

python 报 python 2.7 is required ,which is not found in registry 的错误的解决办法

1 这是由于,在注册表中没有发现该项,而导致的错误,解决办法如下。 新建 register.py 文件 2 把下面的内容 粘贴进,该文件 #    # script to reg...

安装Python-Matplotlib时出现的问题--Python version 2.7 required, which was not found in the registry

今天在安装python的画图包的时候出现了如题的问题,

Python Version 2.7 required which was not found in the registry 问题解决

 今天在安装numpy时,出现了Python Version 2.7 required which was not found in the registry错误,解决方案如下。   Pyt...

Python Version 2.7 required which was not found in the registry 问题解决

今天在安装numpy时,出现了Python Version 2.7 required which was not found in the registry错误,解决方案如下。   Python的...

Delphi7高级应用开发随书源码

  • 2003年04月30日 00:00
  • 676KB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:安装第三方库出现 Python version 2.7 required, which was not found in the registry
举报原因:
原因补充:

(最多只允许输入30个字)