windows环境 pip安装mysqlclient失败问题记录及解决方案

1.问题记录

bash 复制代码
> pip install -i https://pypi.douban.com/simple mysqlclient
Looking in indexes: https://pypi.douban.com/simple
Collecting mysqlclient
  Using cached https://pypi.doubanio.com/packages/50/5f/eac919b88b9df39bbe4a855f136d58f80d191cfea34a3dcf96bf5d8ace0a/mysqlclient-2.1.1.tar.gz
Installing collected packages: mysqlclient
  Running setup.py install for mysqlclient ... error
    ERROR: Command errored out with exit status 1:
MySQ
......
Ldb/_mysql.c(29): fatal error C1083: 无法打开包括文件: "mysql.h": No such file or directory
 error: 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

结果如下:

bash 复制代码
(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
相关推荐
BBB努力学习程序设计2 分钟前
Python函数式编程:优雅的代码艺术
python·pycharm
a***13142 分钟前
redis存取list集合
windows·redis·list
2501_940943917 分钟前
体系课\ Python Web全栈工程师
开发语言·前端·python
田姐姐tmner38 分钟前
Python切片
开发语言·python
t***31651 小时前
爬虫学习案例3
爬虫·python·学习
AI小云2 小时前
【数据操作与可视化】Pandas数据处理-其他操作
python·pandas
大佬,救命!!!2 小时前
更换适配python版本直接进行机器学习深度学习等相关环境配置(非仿真环境)
人工智能·python·深度学习·机器学习·学习笔记·详细配置
无心水2 小时前
【Python实战进阶】4、Python字典与集合深度解析
开发语言·人工智能·python·python字典·python集合·python实战进阶·python工业化实战进阶
上班职业摸鱼人2 小时前
python文件中导入另外一个模块这个模块
python
永远是夏天2 小时前
Python面向对象编程(OOP)全教程:从入门到实战(附案例)
python