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

  • 相关阅读:
    区块链系统时钟同步(NTP时间同步服务器)
    解读GPS卫星同步时钟(NTP网络时间服务器)技术方案
    qsort的cmp函数理解
    IEEE浮点数标准
    看图认识CSS
    Liunx模拟网络延时
    0-4Python2升级3、CentOS-Vim-Golang环境配置
    怎么用Windws远程桌面(mstsc)远程连接服务端的Ubuntu或者CentOS?|内网穿透|服务器安装CentOS
    [Windows]进程无响应且无法在任务管理器关闭
    [python] 批量更改不同文件夹里同名文件夹名字并移动到一起
  • 原文地址:https://www.cnblogs.com/someblue/p/3755433.html
Copyright © 2011-2022 走看看