zoukankan      html  css  js  c++  java
  • 安装python的pywin32安装不了,提示找不到py3.6-32

    安装python的pywin32安装不了,提示找不到py3.6-32

    首先我自己的py3.6是64位版本的,这是pywin32模块的下载地址

    里面有各种版本的,首先我先下了64位的3.6版本的,结果提示这里写图片描述这里写图片描述

    解决方法(亲测有效):

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

    运行这段代码以后可以自动将py3.6安装目录直接添加进注册表,检查了下注册表,的确出现了。

    然后我在试了下64位的exe文件,还是提示找不到注册表。

    然后打开注册表,win+R键,之后输入regedit 
    找到这里这里写图片描述 
    将3.6改为3.6-32,这样就可以进行安装了

     
  • 相关阅读:
    iOS 调试心得
    一步一步带你安装史上最难安装的 vim 插件
    20 行代码极速为 App 加上聊天功能
    在通知栏上玩游戏,Steve iOS 游戏实现思路
    ThinkPHP 3.2.x 集成极光推送指北
    MkDocs 文档生成逻辑浅析
    极光推送的角标问题
    聊天界面-自适应文字
    Python3.7源码包编译安装
    Navicat远程连接MySQL数据库
  • 原文地址:https://www.cnblogs.com/liu--huan/p/10722760.html
Copyright © 2011-2022 走看看