安裝PIL庫(kù)的時(shí)候,直接提示:Python version 2.7 required, which was not found in the registry。
如圖:
大意是說(shuō)找不到注冊(cè)表,網(wǎng)上搜索解決方案。
新建一個(gè)register.py文件寫(xiě)入代碼:
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!"
啟動(dòng)命令切到register.py文件目錄下執(zhí)行:
重新安裝PIL,錯(cuò)誤解決,安裝成功。
如果是win7 64位的用戶(hù)在安裝Python 32位程序時(shí),如果選擇只為當(dāng)前用戶(hù),以上問(wèn)題不會(huì)出現(xiàn)。如果選擇所有用戶(hù),就試著使用以上方法解決。
提示其它版本解決方法類(lèi)似。
更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主
微信掃碼或搜索:z360901061

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