zoukankan      html  css  js  c++  java
  • 【转】Python version 2.7 required, which was not found in the registry

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

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

    方法:

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

     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()

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

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

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

  • 相关阅读:
    Server Tomcat v8.5 Server at localhost failed to start.
    使用bootstrap中的bootstrapValidator,验证ckeditor富文本框不为空
    百度WebUploader上传图片,图片回显编辑,查看
    百度WebUploader上传图片
    做webapp静态页面的一些积累
    ztree插件的使用
    highcharts曲线图
    ajax的表单提交,与传送数据
    一条数据中需要遍历多条数据,页面遍历方法
    在页面中使用拼接字符串的方式显示动态加载的数据
  • 原文地址:https://www.cnblogs.com/someblue/p/3755433.html
Copyright © 2011-2022 走看看