win8环境如何安装python的pycurl

下了一个pycrul的exe安装包,但安装几个版本都出现( Python version 2.7 required, which was not found in the registry)错误  解决方法如下:

新建立一个 register.py  把以下代码拷贝过去 并运行代码,若出现:--- Python 2.7 is now registered!   表示可以正常安装

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_CURRENT_USER, regpath)
    except EnvironmentError as e:
        try:
            reg = CreateKey(HKEY_CURRENT_USER, 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()


本文:win8环境如何安装python的pycurl
文章地址:/ww/4.html 转载请保留链接地址

上一篇:搜索策略之分析搜索需求
下一篇:如何明确seo目标