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

2017-07-21

记录一下python的学习

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

 

然后直接执行 python registry.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()

 

作者:robotbird, 分类:关于代码 标签: python , 浏览(798), 评论(1)
上一篇: 人不过是生命游戏中的一种角色
下一篇: 从今天开始坚持不刷技术类文章

相关文章

(1)条评论 订阅

  1. ${item.nickname} 币安 说:

    很好的支持下了,很好啊。

1

发表评论

电子邮件用于回复通知和avatar全球唯一头像 *

*