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 = “SOFTWAREPythonPythoncore%s” % (version)
installkey = “InstallPath”
pythonkey = “PythonPath”
pythonpath = “%s;%sLib;%sDLLs” % (
    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免费学习笔记(深入)”;

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

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

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

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

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。

发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2290836.html

(0)
上一篇 2025年2月28日 00:35:13
下一篇 2025年2月27日 01:38:40

AD推荐 黄金广告位招租... 更多推荐

相关推荐

发表回复

登录后才能评论