欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2023-11-26 16:50:40
安装pil库的时候,直接提示:python version 2.7 required, which was not found in the registry。 如图:...

安装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文件目录下执行:

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

重新安装pil,错误解决,安装成功。

如果是win7 64位的用户在安装python 32位程序时,如果选择只为当前用户,以上问题不会出现。如果选择所有用户,就试着使用以上方法解决。

提示其它版本解决方法类似。