gpt4 book ai didi

python - 当我运行 Flask 时,它显示错误 : ModuleNotFoundError: No module named 'werkzeug.contrib' . 谁能帮我解决这个问题?

转载 作者:行者123 更新时间:2023-12-03 13:43:26 31 4
gpt4 key购买 nike

我得到的确切错误是:

flask.cli.NoAppException: While importing "application", an ImportError was raised:Traceback      (most recent call last):
File "/home/harshit/.local/lib/python3.6/site-packages/flask/cli.py", line 240, in locate_app
__import__(module_name)
File "/home/harshit/Documents/project1/application.py", line 18, in <module>
Session(app)
File "/home/harshit/.local/lib/python3.6/site-packages/flask_session/__init__.py", line 54, in __init__
self.init_app(app)
File "/home/harshit/.local/lib/python3.6/site-packages/flask_session/__init__.py", line 61, in init_app
app.session_interface = self._get_interface(app)
File "/home/harshit/.local/lib/python3.6/site-packages/flask_session/__init__.py", line 93, in _get_interface
config['SESSION_USE_SIGNER'], config['SESSION_PERMANENT'])
File "/home/harshit/.local/lib/python3.6/site-packages/flask_session/sessions.py", line 313, in __init__
from werkzeug.contrib.cache import FileSystemCache
ModuleNotFoundError: No module named 'werkzeug.contrib'

我正在尝试从 Flask 导入 session

最佳答案

Werkzeug 1.0.0 删除了弃用的代码,包括所有 werkzeug.contrib .您应该为新项目使用替代库。 werkzeug.contrib.session被提取到 secure-cookie .

如果您正在使用的现有项目需要来自 contrib 的东西,您需要降级到 Werkzeug<1:

pip3 install Werkzeug<1

关于python - 当我运行 Flask 时,它显示错误 : ModuleNotFoundError: No module named 'werkzeug.contrib' . 谁能帮我解决这个问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60624139/

31 4 0