当前位置: 代码迷 >> 综合 >> pyCharm提示No module named ‘MySQLdb‘
  详细解决方案

pyCharm提示No module named ‘MySQLdb‘

热度:43   发布时间:2024-02-24 09:39:45.0

文章目录

  • 异常
  • 解决办法
  • 安装到哪了
  • 参考博客

异常

在运行一个py程序时,提示No module named 'MySQLdb'
在这里插入图片描述

解决办法

cmd中直接安装mysqlclient,当然这个项目我选择的是使用系统的python编译器

C:\Users\lenovo>pip3 install mysqlclient
Collecting mysqlclientWARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out. (read timeout=15)")': /packages/4a/28/b08ede6cc8382179201455c3b9e5ed0d66aa5921e7c1888828dba48b832b/mysqlclient-2.0.1-cp37-cp37m-win_amd64.whlDownloading mysqlclient-2.0.1-cp37-cp37m-win_amd64.whl (268 kB)|████████████████████████████████| 268 kB 1.9 kB/s
Installing collected packages: mysqlclient
Successfully installed mysqlclient-2.0.1

安装到哪了

通过上述方式安装的依赖包,可以在python_home下的Lib/site-packages目录下找到
如,我的安装在以下位置

D:\Program Files\Python37\Lib\site-packages\mysqlclient-2.0.1.dist-info

参考博客

https://blog.csdn.net/qq_769932247/article/details/88188945
https://blog.csdn.net/sophie1314/article/details/103502821

  相关解决方案