码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2014-06-29 14:45:14      阅读:312      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   java   color   

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

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

 

方法:

 

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

 

bubuko.com,布布扣
 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()
bubuko.com,布布扣

运行一下就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

标签:des   style   blog   http   java   color   

原文地址:http://www.cnblogs.com/someblue/p/3755433.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!