問(wèn)題表述:
pip install MySQL-python==1.2.5
出現(xiàn)如下報(bào)錯(cuò):
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
運(yùn)行環(huán)境:
windows 10 x64
Python 2.7.14
pip 9.0.1
解決辦法:
看pip的安裝報(bào)錯(cuò)有關(guān)于"MySQL Connector C 6.0.2"泞遗,需要安裝對(duì)應(yīng)的驅(qū)動(dòng)包柏卤,下載地址見(jiàn)下哎垦,
安裝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的一些運(yùn)行庫(kù)箫措,下載地址:
http://www.microsoft.com/en-us/download/confirmation.aspx?id=44266
在win7下安裝了python后,想安裝python-mysql哎迄,使用pip安裝出現(xiàn)如下問(wèn)題:
- 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
網(wǎng)上一般的解釋是回右,重新安裝mysql并在安裝mysql是選擇安裝c++的編譯器。芬失。楣黍。
我雖然沒(méi)試過(guò)匾灶,但感覺(jué)肯定行不通啊棱烂,我只是想裝一個(gè)可以讓python遠(yuǎn)程連接mysql的包而已,管本地mysql什么事阶女?有些解釋真是誤人子弟颊糜。
但錯(cuò)誤提示里也謝了缺少C++的相關(guān)環(huán)境,后來(lái)在網(wǎng)上找到方法了:
方法如下:
1.在 http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python 下載對(duì)應(yīng)的包版本秃踩,如果是win7 64位2.7版本的python衬鱼,就下載
MySQL_python-1.2.5-cp27-none-win_amd64.whl
然后在命令行執(zhí)行pip install MySQL_python-1.2.5-cp27-none-win_amd64.whl
當(dāng)然需要在cmd下跳轉(zhuǎn)到下載MySQL_python-1.2.5-cp27-none-win_amd64.whl的目錄下
然后就安裝成功了MySQL-python