ModuleNotFoundError:即使已安装,也没有名为“flask_mysqldb”的模块
Posted
技术标签:
【中文标题】ModuleNotFoundError:即使已安装,也没有名为“flask_mysqldb”的模块【英文标题】:ModuleNotFoundError: No module named 'flask_mysqldb' even if installed 【发布时间】:2021-01-27 13:25:34 【问题描述】:我正在使用 mysql 和烧瓶来开发基本网站,即使我安装了模块,我也会收到 ModuleNotFound 错误。有人可以解决这个问题吗?
File "c:/Users/prshi/Desktop/Py files/FLASK app/app.py", line 3, in <module>
from flask_mysqldb import MySQL
ModuleNotFoundError: No module named 'flask_mysqldb'
PS C:\Users\prshi\Desktop\Py files\FLASK app> pip install flask-mysqldb
Requirement already satisfied: flask-mysqldb in c:\python39\lib\site-packages (0.2.0)
Requirement already satisfied: Flask>=0.10 in c:\python39\lib\site-packages (from flask-mysqldb) (1.1.2)
Requirement already satisfied: mysqlclient in c:\python39\lib\site-packages (from flask-mysqldb) (1.4.6)
Requirement already satisfied: Werkzeug>=0.15 in c:\python39\lib\site-packages (from Flask>=0.10->flask-mysqldb) (1.0.1)
Requirement already satisfied: Jinja2>=2.10.1 in c:\python39\lib\site-packages (from Flask>=0.10->flask-mysqldb) (2.11.2)
Requirement already satisfied: itsdangerous>=0.24 in c:\python39\lib\site-packages (from Flask>=0.10->flask-mysqldb) (1.1.0)
Requirement already satisfied: click>=5.1 in c:\python39\lib\site-packages (from Flask>=0.10->flask-mysqldb) (7.1.2)
Requirement already satisfied: MarkupSafe>=0.23 in c:\python39\lib\site-packages (from Jinja2>=2.10.1->Flask>=0.10->flask-mysqldb) (1.1.1)
PS C:\Users\prshi\Desktop\Py files\FLASK app>
【问题讨论】:
【参考方案1】:这是一个常见的 python 路径问题,为确保不是您的情况,请键入:
import sys
print(sys.path)
并检查它是否包含:
/usr/local/lib64/python3.6/site-packages
问题是您在某处使用 pip 安装了该软件包,并且您试图从其他未安装它的地方导入它。解决它的诀窍是运行以下命令:
export PYTHONPATH=$PYTHONPATH:/path/to/your/modules
【讨论】:
嘿,是的,它确实包含站点包 太好了,现在导出命令解决了您的问题吗?如果你想更清楚地解释为什么会这样,我推荐PYTHONPATH tip以上是关于ModuleNotFoundError:即使已安装,也没有名为“flask_mysqldb”的模块的主要内容,如果未能解决你的问题,请参考以下文章
PyCharm 显示 ModuleNotFoundError: No module named 'cv2' 即使它已成功安装 [重复]
ModuleNotFoundError:即使我安装了功能工具,也没有名为“功能工具”的模块
ModuleNotFoundError:即使我安装了 pip install websocket,也没有名为“websocket”的模块
ModuleNotFoundError: No module named 'webdriver_manager' 错误即使在安装 webdrivermanager 之后
ModuleNotFoundError: No module named 'bs4' 即使我已经使用 pip3 (Windows) 正确安装了 BeautifulSoup4