程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Python >> Python version 2.7 required, which was not found in the regi

Python version 2.7 required, which was not found in the regi

編輯:Python

安裝PIL庫的時候,直接提示:Python version 2.7 required, which was not found in the registry

 

如圖:

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位程序時,如果選擇只為當前用戶,以上問題不會出現。如果選擇所有用戶,就試著使用以上方法解決。

提示其它版本解決方法類似。

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved