安裝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,這樣就可以進行安裝了

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM