最近在看关于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的时候注册表没有写入对应的位置。
解决办法如下:
1.新建一个reg.py,输入如下代码
17
version
=
sys.version[:
3
]
18
installpath
=
sys.prefix
20
regpath
=
"SOFTWARE\\Python\\Pythoncore\\%s\\"
%
(version)
21
installkey
=
"InstallPath"
22
pythonkey
=
"PythonPath"
23
pythonpath
=
"%s;%s\\Lib\\;%s\\DLLs\\"
%
(
24
installpath, installpath, installpath
29
reg
=
OpenKey(HKEY_CURRENT_USER, regpath)
30
except
EnvironmentError as e:
32
reg
=
CreateKey(HKEY_CURRENT_USER, regpath)
33
SetValue(reg, installkey, REG_SZ, installpath)
34
SetValue(reg, pythonkey, REG_SZ, pythonpath)
37
print
"*** Unable to register!"
39
print
"--- Python"
, version,
"is now registered!"
41
if
(QueryValue(reg, installkey)
=
=
installpath
and
42
QueryValue(reg, pythonkey)
=
=
pythonpath):
44
print
"=== Python"
, version,
"is already registered!"
47
print
"*** Unable to register!"
48
print
"*** You probably have another Python installation!"
50
if
__name__
=
=
"__main__"
:
保存到任意位置,然后用 用在cmd下 执行如下命令。---前提是配置好了python的环境变量
执行后会看到显示注册成功,如图。
再进行MySQL-python-1.2.4b4.win32-py2.7 安装程序,就能一路顺畅了!