最近在安装mysql -python 时报错折腾了半天,通过以下方法解决:
1. pip install mysql-python报错 Unable to find vcvarsall.bat
(参考网上链接http://blog.csdn.net/secretx/article/details/17472107)
解决方法:我的vs版本是2013所以设置环境变量: VS90COMNTOOLS=%VS120COMNTOOLS%
设置好后错误Unable to find vcvarsall.bat不再出现,但出现 fatal error C1083: Cannot open include file: 'config-win.h': No such file or directory
2. 解决错误:fatal error C1083: Cannot open include file: 'config-win.h': No such file or directory
(参考网上链接:http://blog.csdn.net/xxm524/article/details/48754139)
1) 安装mysql connector, 可根据系统版本选择安装32位或64位的, 下载地址:
http://dev.mysql.com/downloads/connector/c/6.0.html#downloads
2) 安装Microsoft Visual C++ Compiler for Python 2.7,要是安装mysql-python需要乃至vc的一些运行库,下载地址:
http://www.microsoft.com/en-us/download/confirmation.aspx?id=44266
再次 pip install mysql-python仍然有错误
3)解决方法:mysql connector之前安装的是64位,安装到了C:\Program Files \MySQL\MySQL Connector C 6.0.2目录,但从提示中看它要的是安装到C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2,因此应该安装32位的mysql connector;
重新安装32位的mysql connector, 重新执行pip install MySQL-python
仍然报错error: command 'mt.exe' failed with exit status 31
3.解决错误error: command 'mt.exe' failed with exit status 31
编辑Python27\Lib\distutils\msvc9compiler.py,查找ld_args.append('/MANIFESTFILE:' + temp_manifest)一行,在其后添加一行,内容为ld_args.append('/MANIFEST')
再次pip install mysql-python 安装成功