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:\progra~2\jetbra~1\python~1\saplat~1\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",需要安装对应的驱动包,下载地址见下,

在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

   http://blog.51cto.com/lmjshe/2066853

猜你喜欢

转载自blog.csdn.net/m0_37235489/article/details/79307457
今日推荐