【已解决】PIL安装异常 “python version 2.7 required, which was not found in the registry.”
2016-01-09 11:21
627 查看
windows下安装PIL,报出异常
经多番搜索,找到如下解决方案。新建register.py(名字随意),代码如下:
cmd切换到脚本目录,执行 python register.py,重新运行安装程序,错误解决!
经多番搜索,找到如下解决方案。新建register.py(名字随意),代码如下:
#!/usr/bin/env python # -*- coding:utf-8 -*- 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!" RegisterPy()
cmd切换到脚本目录,执行 python register.py,重新运行安装程序,错误解决!
相关文章推荐
- python 包的引用 __init__.py
- python中的pip安装
- 一些二叉树相关算法Python的解决
- 【python】pycharm5.0 注册码
- Python3.4连接MySQL的环境搭建步骤
- [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/test-easy-install-1433.pth'
- python定时下载FTP指定文件
- 星球大战与 Python 之间的那些事
- python join(), bool(), strip(), dict()
- Python学习-使用matplotlib画动态多图
- 学习了初级的Python
- [俄勒冈大学]养成Python写作习惯
- Python—模块
- python中带星号/一个星号/两个星号的参数
- Python/C API 实用函数(部分)
- python之三层菜单递归
- Python 过滤字符串的技巧,map与itertools.imap
- Python设计模式之抽象工厂模式
- 介绍Python中的文档测试模块
- Python爬虫工程师面试问题总结