Python Version 2.7 required which was not found in the registry
2017-02-20 19:56
435 查看
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(https://img-blog.csdn.net/20170220195639403?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc21hbGxmbHlpbmdwaWc=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
问题重现
在windows下安装 python 2.7 64bit,在安装时候选择的是“所有用户”下载的PIL是PIL 1.1.7 for python 2.7的windows安装包
在按钻过过程中出现了这个问题
如果你很急迫,可以跳过中间几个方法,直接看最后一个方法。
解决方案
官方解决方案
Adding Python Information to the Windows Registry在PIL的官网上给出了一个script,用于解决python没有注册的问题,内容如下:
# # script to register Python 2.0 or later for use with win32all # and other extensions that require Python registry settings # # written by Joakim Löw for Secret Labs AB / PythonWare # # source: # http://www.pythonware.com/products/works/articles/regpy20.htm 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_LOCAL_MACHINE, regpath) except EnvironmentError: try: reg = CreateKey(HKEY_LOCAL_MACHINE, 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()
这个脚本的功能就是在注册表下HKEY_LOCAL_MACHINE\SOFTWARE\Python\Pythoncore\Python 2.7下新建两个项,一个是python 的安装路径PythonPath,一个是第三方库的安装路径InstallPath,并给出他们的值,官网上同时给出了删除这两个注册表项的代码:
def UnRegisterPy(): try: reg = OpenKey(HKEY_LOCAL_MACHINE, regpath) except EnvironmentError: print "*** Python not registered?!" return try: DeleteKey(reg, installkey) DeleteKey(reg, pythonkey) DeleteKey(HKEY_LOCAL_MACHINE, regpath) except: print "*** Unable to un-register!" else: print "--- Python", version, "is no longer registered!"
注意这只是个函数,需要将它添加到上一个脚本中,并在main中调用。
有很多人使用这个方法就成功了。但是我没有成功,我给出的错误信息是:
*** Unable to register! *** You probably have another Python installation!
也就是已经有这两个注册表项了。
博友给出的方案
CSDN上有博友给出了一个方案,我没有测试。但是根据评论很多人成功了。Python Version 2.7 required which was not found in the registry 问题解决
下面的内容摘自他的博客,侵删。
Python的一些第三方库只到注册表的HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.7\InstallPath路径下寻找Python。但是装好的64位Python在HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.7\InstallPath路径下建立Python的信息。所以,在cmd输入regedit然后将HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.7\InstallPath路径下的值,复制到HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.7\InstallPath路径下,当然没有路径的话一定要新建起来。 然后就可以安装了。 本解决方案适用于安装numpy,SetupTools等只提供了32位安装包的库。 P.S Python的功能很大 4000 程度上取决于第三方库,但是很多开发这并不喜欢提供64位版本。上面方法只是个参考,其实最靠谱的解决方案1、Python和第三方库都装成32位;2、把第三方库文件下载下来,重新编译。
我虽然没有用这个方法(太麻烦,而且要手动添加注册表),但是我找到了我安装失败的原因,就是我安装的python是64bit的,这才是问题的关键,PIL是32bit的,而我的python是64bit的,所以才会提示没有注册python.
最简单的解决办法
重装python,安装成32bit的即可。成功。参考
Adding Python Information to the Windows RegistryPython Version 2.7 required which was not found in the registry 问题解决
相关文章推荐
- Python version 2.7 required, which was not found in the registry
- Python version 2.7 required, which was not found in the registry
- Python version 2.7 required, which was not found in the registry.
- 安装Python-Matplotlib时出现的问题--Python version 2.7 required, which was not found in the registry
- python version 2.7 required,which was not found in the registry
- Python version 2.7 required, which was not found in the registry
- 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 问题解决
- windows安装python mysqldb时报错python version 2.7 required,which was not found in the registry
- (转)Python Version 2.7 required which was not found in the registry 问题解决
- Python version 2.7 required, which was not found in the registry
- python2安装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
- 安装第三方库出现 Python version 2.7 required, which was not found in the registry
- 安装第三方库出现 Python version 2.7 required, which was not found in the registry
- 安装第三方库出现 Python version 2.7 required, which was not found in the registry
- python version 2.7 required,which was not found in the registry
- 安装第三方库出现 Python version 2.7 required, which was not found in the registry
- python error python version 2.7 required,which was not found in the registry