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
相关推荐
bellus-6 分钟前
ubuntu26测试win10的ollama大模型性能
python
水木流年追梦7 分钟前
大模型入门-Reward 奖励模型训练
开发语言·python·算法·leetcode·正则表达式
JavaWeb学起来7 分钟前
Python学习教程(六)数据结构List(列表)
数据结构·python·python基础·python教程
liuyunshengsir20 分钟前
PyTorch 动态量化(Dynamic Quantization)
人工智能·pytorch·python
电子云与长程纠缠29 分钟前
UE5制作六边形包裹球体效果
开发语言·python·ue5
DFT计算杂谈38 分钟前
KPROJ编译教程
java·前端·python·算法·conda
qq_369224331 小时前
Windows系统缺失ddraw.dll文件?游戏闪退、图形报错原因详解及处理办法
windows·游戏·dll·dll修复·dll丢失·dll错误
念恒123061 小时前
Python(循环中断)
开发语言·python
林下溪畔1 小时前
部署claude code(Windows版)
windows
tsfy20031 小时前
Python 处理中文文件名的3个坑(附 Flask 上传解决函数)
开发语言·python·flask·文件上传·中文编码