python version 2.7 required,which was not find in the registry

最近在看关于DHT网络爬虫的相关东西,然而DHT爬虫好多案列都是用的python来写的。没办法就开始去学习下python。

今天在本地搭建python的时候,安装MySQL-python-1.2.4b4.win32-py2.7 出现 错误:python version 2.7 required,which was not find in the registry

 当时我就吓尿了,我明明安装了python啊,还提示我没有找到。  谷歌之后才知道因为我的操作系统是win7 64位导致安装python的时候注册表没有写入对应的位置。

20130516004951553.jpg 

 解决办法如下:

  1.新建一个reg.py,输入如下代码

01 #
02 # script to register Python 2.0 or later for use with win32all
03 # and other extensions that require Python registry settings
04 #
05 # written by Joakim Loew for Secret Labs AB / PythonWare
06 #
07 # source:
08 # http://www.pythonware.com/products/works/articles/regpy20.htm
09 #
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()
保存到任意位置,然后用 用在cmd下 执行如下命令。---前提是配置好了python的环境变量

1 python reg.py
执行后会看到显示注册成功,如图。

QQ截图20140424172500.png


再进行MySQL-python-1.2.4b4.win32-py2.7 安装程序,就能一路顺畅了!


20130516005541942.jpg


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值