ModuleNotFoundError,即使我已经安装了它与pip



我正在尝试导入python包,但它不会工作。每个包裹都失败了。当我尝试pip install或conda install时,它说要求已经满足了…

当我在终端使用python时,

进口mysql也不行

这是我的终端的内容:

(venv) C:Users<user>DocumentsMes DocumentsCodeFichiers13_sql_w_python>pip install mysql
Requirement already satisfied: mysql in c:users<user>anaconda3envsvenvlibsite-packages (0.0.3)
Requirement already satisfied: mysqlclient in c:users<user>anaconda3envsvenvlibsite-packages (from mysql) (2.1.1)
(venv) C:Users<user>DocumentsMes DocumentsCodeFichiers13_sql_w_python>C:/Users/<user>/anaconda3/envs/venv/python.exe "c:/Users/<user>/Documents/Mes Documents/Code/Fichiers/13_sql_w_python/test.py"
Requirement already satisfied: mysql in c:users<user>anaconda3envsvenvlibsite-packages (0.0.3)
Requirement already satisfied: mysqlclient in c:users<user>anaconda3envsvenvlibsite-packages (from mysql) (2.1.1)
Traceback (most recent call last):
File "c:Users<user>DocumentsMes DocumentsCodeFichiers13_sql_w_pythontest.py", line 5, in <module>
import mysql
ModuleNotFoundError: No module named 'mysql'
(venv) C:Users<user>DocumentsMes DocumentsCodeFichiers13_sql_w_python>

我试过安装和卸载vscode和anaconda,我试过搞乱python的路径,但似乎没有工作

mysql实际上只是一个安装mysqlclient的元包(在pip输出中看到了吗?)当然,你也不能只导入mysqlclient,因为那太简单了。

您需要使用import MySQLdb

见:https://mysqlclient.readthedocs.io/user_guide.html

相关内容

  • 没有找到相关文章

最新更新