安装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,这样就可以进行安装了