zoukankan      html  css  js  c++  java
  • Python version 2.7 required, which was not found in the registry

    http://blog.csdn.net/zklth/article/details/8117207

     1 import sys
     2 
     3 from _winreg import *
     4 
     5 # tweak as necessary
     6 version = sys.version[:3]
     7 installpath = sys.prefix
     8 
     9 regpath = "SOFTWARE\Python\Pythoncore\%s\" % (version)
    10 installkey = "InstallPath"
    11 pythonkey = "PythonPath"
    12 pythonpath = "%s;%s\Lib\;%s\DLLs\" % (
    13     installpath, installpath, installpath
    14 )
    15 
    16 
    17 def RegisterPy():
    18     try:
    19         reg = OpenKey(HKEY_CURRENT_USER, regpath)
    20     except EnvironmentError as e:
    21         try:
    22             reg = CreateKey(HKEY_CURRENT_USER, regpath)
    23             SetValue(reg, installkey, REG_SZ, installpath)
    24             SetValue(reg, pythonkey, REG_SZ, pythonpath)
    25             CloseKey(reg)
    26         except:
    27             print "*** Unable to register!"
    28             return
    29         print "--- Python", version, "is now registered!"
    30         return
    31     if (QueryValue(reg, installkey) == installpath and
    32                 QueryValue(reg, pythonkey) == pythonpath):
    33         CloseKey(reg)
    34         print "=== Python", version, "is already registered!"
    35         return
    36     CloseKey(reg)
    37     print "*** Unable to register!"
    38     print "*** You probably have another Python installation!"
    39 
    40 
    41 if __name__ == "__main__":
    42     RegisterPy()
    
    
  • 相关阅读:
    C/C++ 数据精确度的设置
    Java 接口回调
    ListView + ArrayAdapter + 接口回调
    C/C++内存详解
    第九届蓝桥杯明码
    2018蓝桥杯省赛(C/C++ C组)
    2015蓝桥杯五星填数(C++C组)
    java ee 面试时的机试题
    让div中的table居中
    javascript 调试技巧
  • 原文地址:https://www.cnblogs.com/hello1123/p/7427662.html
Copyright © 2011-2022 走看看