安裝PIL庫的時候,直接提示:Python version 2.7 required, which was not found in the registry
如圖:
大意是說找不到注冊表,網上搜索解決方案。
新建一個register.py文件寫入代碼:
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!"
啟動命令切到register.py文件目錄下執行
重新安裝PIL,錯誤解決,安裝成功。
如果是win7 64位的用戶在安裝Python 32位程序時,如果選擇只為當前用戶,以上問題不會出現。如果選擇所有用戶,就試著使用以上方法解決。
提示其它版本解決方法類似。