64位系統裝了32位的Python,安裝exe格式對應python版本相關的包,報錯:Python version 3.5 required, which was not found in the registry。
原因是注冊表缺少Python安裝信息,安裝時,要注意選擇。
64位系統32位Python,如果使用pywin32出現DLL load failed
復制文件夾
C:\Program Files (x86)\Python36-32\Lib\site-packages\pywin32_system32\
內的文件:pythoncom36.dll
pywintypes36.dll到文件夾C:\Windows\SysWOW64\
+++++++++++++++++++++++++++++++++++++++++
1.右鍵安裝包,“以管理員權限運行”
2.勾選“add Python 3.5 to PATH”,選擇“customize installation”。
3.注意,勾選“for all users”就需要管理員權限運行。
4.勾選“Install for all users”,安裝。
當然,你也可以選擇使用下面了py腳本來添加Python安裝信息:
import sys
from _winreg import *
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()