1.问题记录
> pip install -i https://pypi.douban.com/simple mysqlclient
Looking in indexes: https://pypi.douban.com/simple
Collecting mysqlclientUsing cached https://pypi.doubanio.com/packages/50/5f/eac919b88b9df39bbe4a855f136d58f80d191cfea34a3dcf96bf5d8ace0a/mysqlclient-2.1.1.tar.gz
Installing collected packages: mysqlclientRunning setup.py install for mysqlclient ... errorERROR: Command errored out with exit status 1:
MySQ
......
Ldb/_mysql.c(29): fatal error C1083: 无法打开包括文件: “mysql.h”: No such file or directoryerror: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2----------------------------------------
ERROR: Command errored out with exit status 1:
2.解决方案
直接下载安装mysqlclient whl文件进行安装
https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient
注意:cp37即表示python3.7的版本,其他版本号同理,win32表示windows 32位的, win_amd64表示windows 64位
我这里是python3.7的版本,系统是64位所以选择mysqlclient‑1.4.6‑cp37‑cp37m‑win_amd64.whl
结果如下:
(venv) E:\project\xxx\service>pip install mysqlclient-1.4.6-cp37-cp37m-win_amd64.whl
Processing e:\project\xxx\service\mysqlclient-1.4.6-cp37-cp37m-win_amd64.whl
Installing collected packages: mysqlclient
Successfully installed mysqlclient-1.4.6