欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

pyCharm提示No module named ‘MySQLdb‘

程序员文章站 2022-05-28 23:40:28
...

异常

在运行一个py程序时,提示No module named 'MySQLdb'
pyCharm提示No module named ‘MySQLdb‘

解决办法

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

C:\Users\lenovo>pip3 install mysqlclient
Collecting mysqlclient
  WARNING: 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.whl
  Downloading 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

Windows看监听的端口

程序运行后会监听一个端口,在cmd中可以用下面的命令查看监听情况

C:\Users\lenovo>netstat -ano | findstr 22707
  TCP    0.0.0.0:22707          0.0.0.0:0              LISTENING       5472

参考博客

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

相关标签: Python python