简体   繁体   English

ModuleNotFoundError 即使我已经用 pip 安装了它

[英]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.

相关问题 ModuleNotFoundError:即使我安装了 pip 安装 websocket,也没有名为“websocket”的模块 - ModuleNotFoundError: No module named 'websocket' even though I installed pip install websocket Python 抛出 ModuleNotFoundError 即使我使用 pip install 安装了本地 package - Python throws ModuleNotFoundError even though I installed a local package using pip install 无法在虚拟环境中导入&#39;flask_wtf&#39;和&#39;wtforms&#39;,即使我已经安装了它们? - Unable to import 'flask_wtf' & 'wtforms' in a virtual env even though I've already pip installed them? ModuleNotFoundError:没有名为“google.cloud”的模块,即使我安装了它 - ModuleNotFoundError: No module named 'google.cloud' even though I installed it ModuleNotFoundError:即使我安装了功能工具,也没有名为“功能工具”的模块 - ModuleNotFoundError: No module named 'featuretools' even though I have installed featuretools 即使我已经有 __init__.py 也得到 ModuleNotFoundError - Getting ModuleNotFoundError even though I already have __init__.py 即使安装了pip,也找不到pip [3]命令 - pip[3] command not found even though pip is installed Pip 即使我下载了 python 也显示未安装? - Pip showing up an not installed even though I downloaded python? 即使我安装了 pip,Matplotlib 也无法在 python 中工作 - Matplotlib won't work in python even though i pip installed it ModuleNotFoundError:没有名为“请求”的模块。 即使已经安装了 requests - ModuleNotFoundError: No module named 'requests'. Even though requests has already been installed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM