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()
    
    
  • 相关阅读:
    济南空中课堂视频下载辅助脚本
    npm 修改仓库源
    Java后端实现登陆的方式
    java 新词汇
    数据库系统,设计、实现与管理(基础篇)阅读笔记
    java 面试01
    js rem 适配多端
    了解Java
    linux 查看内存使用情况
    linux 日志查看
  • 原文地址:https://www.cnblogs.com/hello1123/p/7427662.html
Copyright © 2011-2022 走看看