设为首页 加入收藏

TOP

Python version 2.7 required, which was not found in the registry 问题解决
2017-10-09 16:59:56 】 浏览:2894
Tags:Python version 2.7 required which was not found the registry 问题 解决

问题:在安装MySQL-python 1.2.5时出现提示Python version 2.7 required, which was not found in the registry

问题解决如下:执行以下代码,再次安装便可以了!

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函数式编程(进阶2) 下一篇Python模块(进阶3)

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目