windows python MySQL-python安装过程

问题表述:
pip install MySQL-python==1.2.5
出现如下报错:

C:\Users\Administrator\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include" -IC:\Python27\include -Ic:\progra2\jetbra1\python1\saplat1\PC /Tc_mysql.c /Fobuild\temp.win-amd64-2.7\Release_mysql.obj /Zl _mysql.c _mysql.c(42) : fatal error C1083: Cannot open include file: 'config-win.h': No such file or directory error: command 'C:\Users\Administrator\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe' failed with exit status 2

运行环境:
windows 10 x64
Python 2.7.14
pip 9.0.1

解决办法:
看pip的安装报错有关于"MySQL Connector C 6.0.2",需要安装对应的驱动包,下载地址见下,

安装mysql connector,必须安装32位(特么), 下载地址:
http://dev.mysql.com/downloads/connector/c/6.0.html#downloads

安装Microsoft Visual C++ Compiler for Python 2.7,要是安装mysql-python需要乃至vc的一些运行库,下载地址:
http://www.microsoft.com/en-us/download/confirmation.aspx?id=44266
在win7下安装了python后,想安装python-mysql,使用pip安装出现如下问题:

  • pip install MySQL-python

build\lib.win-amd64-2.7_mysql.pyd : fatal error LNK1120: 56 unresolved externals error: command 'C:\Users\Administrator\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\link.exe' failed with exit status 1120

网上一般的解释是,重新安装mysql并在安装mysql是选择安装c++的编译器。。。
我虽然没试过,但感觉肯定行不通啊,我只是想装一个可以让python远程连接mysql的包而已,管本地mysql什么事?有些解释真是误人子弟。
但错误提示里也谢了缺少C++的相关环境,后来在网上找到方法了:
方法如下:
1.在 http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python 下载对应的包版本,如果是win7 64位2.7版本的python,就下载
MySQL_python-1.2.5-cp27-none-win_amd64.whl
然后在命令行执行pip install MySQL_python-1.2.5-cp27-none-win_amd64.whl
当然需要在cmd下跳转到下载MySQL_python-1.2.5-cp27-none-win_amd64.whl的目录下
然后就安装成功了MySQL-python

参考链接:
http://www.cnblogs.com/fnng/p/4115607.html

你可能感兴趣的:(windows python MySQL-python安装过程)