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

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

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

 

方法:

 

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

 

【转】Python version 2.7 required, which was not found in the 
registry
 1 #
 2 # script to register Python 2.0 or later for use with win32all
 3 # and other extensions that require Python registry settings
 4 #
 5 # written by Joakim Loew for Secret Labs AB / PythonWare
 6 #
 7 # source:
 8 # http://www.pythonware.com/products/works/articles/regpy20.htm
 9 #
10 # modified by Valentine Gogichashvili as described in http://www.mail-archive.com/distutils-sig@python.org/msg10512.html
11  
12 import sys
13  
14 from _winreg import *
15  
16 # tweak as necessary
17 version = sys.version[:3]
18 installpath = sys.prefix
19  
20 regpath = "SOFTWARE\\Python\\Pythoncore\\%s\\" % (version)
21 installkey = "InstallPath"
22 pythonkey = "PythonPath"
23 pythonpath = "%s;%s\\Lib\\;%s\\DLLs\\" % (
24     installpath, installpath, installpath
25 )
26  
27 def RegisterPy():
28     try:
29         reg = OpenKey(HKEY_CURRENT_USER, regpath)
30     except EnvironmentError as e:
31         try:
32             reg = CreateKey(HKEY_CURRENT_USER, regpath)
33             SetValue(reg, installkey, REG_SZ, installpath)
34             SetValue(reg, pythonkey, REG_SZ, pythonpath)
35             CloseKey(reg)
36         except:
37             print "*** Unable to register!"
38             return
39         print "--- Python", version, "is now registered!"
40         return
41     if (QueryValue(reg, installkey) == installpath and
42         QueryValue(reg, pythonkey) == pythonpath):
43         CloseKey(reg)
44         print "=== Python", version, "is already registered!"
45         return
46     CloseKey(reg)
47     print "*** Unable to register!"
48     print "*** You probably have another Python installation!"
49  
50 if __name__ == "__main__":
51     RegisterPy()
【转】Python version 2.7 required, which was not found in the 
registry

运行一下就ok了。再安装软件的时候就能识别了。

 

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

 

原帖:http://www.cnblogs.com/min0208/archive/2012/05/24/2515584.html

【转】Python version 2.7 required, which was not found in the registry,布布扣,bubuko.com

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

上一篇:黑马程序员___java断言


下一篇:java经典面试题