• 欢迎访问金笔头博客,这是一个菜鸟(伪)程序员的自留地,欢迎访问我的github:点击进入

[解决方案]Python version 2.7 required, which was not found in the registry

mysql eason 15992次浏览 12个评论 扫描二维码

准备用Python连接远程MySQL,在安装MySQL-python-1.2.4b4.win32-py2.7的时候出现如下错误:Python version 2.7 required, which was not found in the registry

[解决方案]Python version 2.7 required, which was not found in the registry

然而事实是我已经安装好了Python2.7,这里却没找到,一番搜索才知道是系统的问题,我的系统是64位的win7,因此在安装Python的时候注册信息没有写到正确的位置。

解决方案如下:

新建一个reg.py的文件,贴入下列代码并保存:

#
# script to register Python 2.0 or later for use with win32all
# and other extensions that require Python registry settings
#
# written by Joakim Loew for Secret Labs AB / PythonWare
#
# source:
# http://www.pythonware.com/products/works/articles/regpy20.htm
#
# modified by Valentine Gogichashvili as described in http://www.mail-archive.com/distutils-sig@python.org/msg10512.html
 
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()

在reg.py所在目录下打开cmd窗口,执行reg.py,显示注册成功!

[解决方案]Python version 2.7 required, which was not found in the registry

再次安装MySQL-python-1.2.4b4.win32-py2.7.exe,一路顺利。

[解决方案]Python version 2.7 required, which was not found in the registry


金笔头博客, 版权所有丨如未注明 , 均为原创, 转载请注明[解决方案]Python version 2.7 required, which was not found in the registry
喜欢 (11)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
(12)个小伙伴在吐槽
  1. Enjoyed every bit of your blog article.Really looking forward to read more. Fantastic.
    Qadin zinЙ™t Й™Еџyalari vЙ™ kosmetika2016-02-09 16:52 Reply Windows 7 | Firefox 3.5.3
  2. Wow, awesome blog layout! How long have you been blogging for? you made running a blog glance easy. The whole look of your site is magnificent, as well as the content!
    HP DESIGNJET REPAIR2016-02-09 08:06 Reply Windows 7 | Firefox 3.5.3
  3. Hi there! I'm at work surfing around your blog from my new iphone 3gs! Just wanted to say I love reading your blog and look forward to all your posts! Keep up the outstanding work!
    HP PLOTTER REPAIR2016-02-09 07:23 Reply Windows 7 | Firefox 3.5.3
  4. Hi, I log on to your blogs daily. Your writing style is awesome, keep up the good work!
    HP PRINTER REPAIR SERVICE2016-02-09 06:39 Reply 未知操作系统 | Firefox 3.8
  5. Thanks so much for the blog post.Much thanks again. Really Great.
    HP PRINTER REPAIR SERVICE2016-02-09 05:05 Reply Windows XP | Opera 9.64
  6. I cannot thank you enough for the blog article.Really looking forward to read more. Will read on...
    HP DESIGNJET REPAIR2016-02-09 04:12 Reply 未知操作系统 | Firefox 3.8
  7. Hey there, just got receptive to your article through Yahoo and bing, and realized that it's very informative. I will truly appreciate in the event you continue this approach.
    HP DESIGNJET REPAIR2016-02-09 03:30 Reply Windows XP | Opera 9.64
  8. Hey, thanks for the blog.Really thank you! Much obliged.
    anti virus2016-02-09 02:49 Reply Windows XP | Firefox 3.5.3
  9. Very good article post.Really thank you! Keep writing.
    Wedding party bus rental2016-02-07 20:07 Reply Windows 7 | Chrome 4.0.221.7
  10. DfFx9T Yeah bookmaking this wasn at a bad determination outstanding post!.
    fiverr crorkservice2016-02-04 12:14 Reply Windows XP | Internet Explorer 6.0
  11. Wow! This can be one particular of the most helpful blogs We have ever arrive across on this subject. Basically Wonderful. I am also an expert in this topic therefore I can understand your hard work.
    fiverr backlinks2016-02-03 13:29 Reply Windows XP | Firefox 3.5.3
  12. Im thankful for the blog.Really looking forward to read more. Much obliged.
    fiverr backlinks2016-01-02 15:46 Reply Windows XP | Firefox 3.0.14