python如何重新编译安装mysql,成功编译 MySQL-python

安装python2.7,将python的安装目录添加到系统环境变量中。

安装python工具:setuptools、pywin32

确保已经安装 Microsoft Visual C++ 2008 Express Edition

安装mysql-essential-5.1.55-win32.exe, 安装时,要确保安装成开发版本,在安装过程中需要手动添加mysql需要的include、lib\debub、lib\opt,这些需要手动操作,不会自动加入的。英文版本中应该是"Developer Components",手动添加\include, lib\debug and lib\opt。

手动解压mysql-python-1.2.3.tar.gz

进入命令提示符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!!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值