[英]ModuleNotFoundError even though I already installed it with pip
I am trying to import python packages but it won't work.我正在尝试导入 python 包,但它不起作用。 It fails with every package. And when I try pip install or conda install it says that the requirement is already satisfied...每个 package 都会失败。当我尝试 pip 安装或 conda 安装时,它说要求已经满足......
And when in the terminal I use python,当我在终端中使用 python 时,
import mysql won't work either. import mysql 也不起作用。
This is the content of my terminal:这是我终端的内容:
(venv) C:\Users\<user>\Documents\Mes Documents\Code\Fichiers\13_sql_w_python>pip install mysql
Requirement already satisfied: mysql in c:\users\<user>\anaconda3\envs\venv\lib\site-packages (0.0.3)
Requirement already satisfied: mysqlclient in c:\users\<user>\anaconda3\envs\venv\lib\site-packages (from mysql) (2.1.1)
(venv) C:\Users\<user>\Documents\Mes Documents\Code\Fichiers\13_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>\anaconda3\envs\venv\lib\site-packages (0.0.3)
Requirement already satisfied: mysqlclient in c:\users\<user>\anaconda3\envs\venv\lib\site-packages (from mysql) (2.1.1)
Traceback (most recent call last):
File "c:\Users\<user>\Documents\Mes Documents\Code\Fichiers\13_sql_w_python\test.py", line 5, in <module>
import mysql
ModuleNotFoundError: No module named 'mysql'
(venv) C:\Users\<user>\Documents\Mes Documents\Code\Fichiers\13_sql_w_python>
I have tried installing and uninstalling vscode and anaconda, I have tried messing with python path,but nothig seems to work我试过安装和卸载 vscode 和 anaconda,我试过弄乱 python 路径,但似乎没有任何效果
mysql
is actually just a meta-package that installs mysqlclient
(see that in the pip output?). mysql
实际上只是一个安装mysqlclient
的元包(请参阅 pip output?)。 Naturally, you can't just import mysqlclient
either because that would be too easy.当然,您也不能只导入mysqlclient
,因为那样太容易了。
You need to use import MySQLdb
您需要使用import MySQLdb
See: https://mysqlclient.readthedocs.io/user_guide.html参见: https://mysqlclient.readthedocs.io/user_guide.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.