zoukankan      html  css  js  c++  java
  • 在注册表中无Python3.5安装路径的情况下安装pywin32-

    当安装pywin32出现Python Version 3.5 required which was not found in the registry的时候表面注册表中没有Python3.5的安装路径。  
    我出现这种情况是因为我直接用的Anaconda所以注册表没有注册  
    解决办法:  
    1. 先在注册表中写入Python3.5的安装路径。我在网上找到了注册表注册的代码贴出来供大家使用。 

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

    2.然后在直接运行安装文件即可

  • 相关阅读:
    oracle数据库的乱码问题解决方案
    @HTML.checkboxFor()用法
    存储过程实现登录(.net)
    .net中大数据的处理
    xml总结
    获取指定日期是当前月的第几周
    JS中正则方法的使用
    获取指定日期的前一天日期
    通过Oracle函数实现.NET String.Format函数的简单版
    ReportViewer实现多语言
  • 原文地址:https://www.cnblogs.com/cutd/p/5433428.html
Copyright © 2011-2022 走看看