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.然后在直接运行安装文件即可

  • 相关阅读:
    How To Scan QRCode For UWP (4)
    How To Crop Bitmap For UWP
    How To Scan QRCode For UWP (3)
    How To Scan QRCode For UWP (2)
    How To Scan QRCode For UWP (1)
    How to change windows applicatioin's position via Win32 API
    8 Ways to Become a Better Coder
    How to resize or create a thumbnail image from file stream on UWP
    C# winform压缩文件夹带进度条
    MS ACCESS MID函数
  • 原文地址:https://www.cnblogs.com/cutd/p/5433428.html
Copyright © 2011-2022 走看看