成功编译 MySQL-python

以下方法使用于 python2.6  python2.7
 
需要准备以下工具:
我使用的版本为python2.7,相应版本的工具为:
python2.7
setuptools-0.6c11.win32-py2.7
pywin32-214.win-py2.7
MySQL-python-1.2.3.tar.gz
mysql-essential-5.1.55-win32.exe
Microsoft Visual C++ 2008 Express Edition(可以从微软官网免费下载)
 
  1. 安装python2.7,将python的安装目录添加到系统环境变量中。
  2. 安装python工具:setuptools、pywin32
  3. 确保已经安装 Microsoft Visual C++ 2008 Express Edition
  4. 安装mysql-essential-5.1.55-win32.exe, 安装时,要确保安装成开发版本,在安装过程中需要手动添加mysql需要的include、lib\debub、lib\opt,这些需要手动操作,不会自动加入的。英文版本中应该是"Developer Components",手动添加\include, lib\debug and lib\opt。
  5. 手动解压mysql-python-1.2.3.tar.gz
  6. 进入命令提示符cmd ,进入mysql-python解压的那个目录。
    命令:
     python setup.py build
    如果出现错误:
    in get_config
    serverKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, options['registry_key'])
    WindowsError: [Error 2] The system cannot find the file specified

    请修改文件:site.cfg
    修改内容为: registry_key = SOFTWARE\MySQL AB\MySQL Server 5.1,以前版本为5.0,
    继续   python setup.py build

    如果出现类似错误:
    build\temp.win32-2.6\Release\_mysql.pyd.manifest : general error c1010070: Failed to load and parse the manifest. The system cannot find  the file specified.
    error: command ‘mt.exe’ failed with exit status 31

    请修改文件:Python26\Lib\distutils\msvc9compiler.py,修改内容为:
    查找字符串‘MANIFESTFILE’,在类似字段
    ld_args.append(‘/MANIFESTFILE:’ + temp_manifest)
    在该行后边添加一行:
    ld_args.append(‘/MANIFEST’)

    继续:  python setup.py build

    应该就成功了.
    然后 python  setup.py install 

    python
    >> import MySQLdb
    OK!
    以上方法适用于python2.6与python2.7。

    编译MySQL-python的关键在于: 合适的VS编译器,如果要编译python2.5中的MySQl,请使用vs2003,对于2.6  2.7可以使用vs2008。


    HAVE  FUN!!!

<script type=text/javascript charset=utf-8 src="http://static.bshare.cn/b/buttonLite.js#style=-1&uuid=&pophcol=3&lang=zh"></script> <script type=text/javascript charset=utf-8 src="http://static.bshare.cn/b/bshareC0.js"></script>
阅读(617) | 评论(0) | 转发(0) |
0

上一篇:dll加载FAQ

下一篇:全面解析sizeof

给主人留下些什么吧!~~
评论热议
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值