安裝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位程序時,如果選擇只為當前用戶,以上問題不會出現。如果選擇所有用戶,就試著使用以上方法解決。
提示其它版本解決方法類似。
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
