码迷,mamicode.com
首页 > 数据库 > 详细

webpy 开发环境搭建问题之Mysql-python安装

时间:2014-12-02 22:21:36      阅读:267      评论:0      收藏:0      [点我收藏+]

标签:des   http   io   ar   os   sp   for   on   文件   

  关于python核心编程已经看了差不多,准备搞些框架方面的学习,本来想打算看看Django的,但是朋友推荐先看看轻量级的flask或者webpy的开发,所以晚上回来,搭建下开发环境(PS:搭建过程中由于网上参考资料难免多多少少会出点问题。)

  在搭建webpy开发环境的过程中遇到安装mysql出错,提示为

Python version 2.7 required, which was not found in the registry

  不过通过万能的互联网还是找到了解决方法:

  本人在e盘根目录下创建一个register.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()

  最后在cmd命令行执行这段代码后,重新安装mysql就可以找打注册信息以及python的安装路径了。

webpy 开发环境搭建问题之Mysql-python安装

标签:des   http   io   ar   os   sp   for   on   文件   

原文地址:http://www.cnblogs.com/Tony-zhangl/p/4138592.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!