貌似有exe可执行文件,但是好歹手动编译了一下,了解了一些参数。
第一次运行:
in get_config
serverKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, options['registry_key'])
WindowsError: [Error 2] The system cannot find the file specified
在网上找到了,默认搜索注册表HKEY_LOCAL_MACHINE/SOFTWARE/MySQL AB/MySQL Server 5.0,我用的是5.5,在site.cfg中改成5.5即可
继续运行,报错
_mysql.c(34) : fatal error C1083: 无法打开包括文件:“config-win.h”: No such fe or directory
很明显,需要用到mysql提供的头文件,找不到地址。
在site.cfg中添加connector = f:\*\mysql-connector\include\作为include文件夹的地址,然后在setup_windows.py中进行修改include_dirs参数,include_dirs = [ os.path.join(mysql_root, r'include', options['connector']) ]。个人觉得应该可以通过mysql_root来指定头文件目录(我安装的时候忘了添加开发包)。
继续运行,仍然报错
LINK : fatal error LNK1181: 无法打开输入文件“mysqlclient.lib”
问题和上面一个一样,找不到包含的库文件。
同样修改setup_windows.py中的library_dirs参数,此处省略。
继续运行
build\temp.win32-2.7\Release\_mysql.pyd.manifest : general error c1010070: Faile
to load and parse the manifest. The system cannot find the file specified.
error: command ‘mt.exe’ failed with exit status 31
在C:\Python27\Lib\distutils中修改msvc9compiler.py,
在 ld_args.append(‘/MANIFESTFILE:’ + temp_manifest)一行下添加ld_args.append(‘/MANIFEST’)
再运行,至此大功告成
参考了http://fuyun.org/2009/12/install-mysql-for-python-on-windows/和http://stackoverflow.com/questions/1972259/mysql-python-install-problem-using-virtualenv-windows-pip