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

安装setuptools的时候,不能再注册表中识别出来python2.7

在网上找了方法,仅作笔记,供下次使用:

下载和安装Python的第三方图像处理的库:PIL(Python Imaging Library)

下载PIL

找到官网:

http://www.pythonware.com/products/pil/

下载和我的环境:

  • win7 x64
  • Python 2.7

所匹配的:

Python Imaging Library 1.1.7 for Python 2.7

注:此处没有x64版本可下载,只能下载32位的了。

安装结果出错:python version 2.7 required which was not found in the registry

最后在网上找到方法:

新建一个register.py 文件,把一下代码贴进去,保存(F盘)

#
# script to register Python 2.0 or later for use with win32all
# and other extensions that require Python registry settings
#
#
# source:
#
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!"
 
if __name__ == "__main__":
    RegisterPy()


register.py放在F根目录,用cd到F盘,运行python register.py

显示“python 2.7 is already registered”

再安装setuptools的时候,就能自动识别出来python2.7了。

win7是 64的原因,在安装python(32位)时,如果选择只为当前用户,以上问题是不会出现的,如果选择所有用户,那就用上面的方法解决吧。

 

代码来自:http://tech.valgog.com/2010/01/after-installing-64-bit-windows-7-at.html




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值