本文介绍了当我执行Flask运行时,它显示错误:ModuleNotFoundError:没有名为"werkzeug.contrib"的模块.谁能帮我这个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到的确切错误是:

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导入会话

I am trying to import sessions from Flask

推荐答案

Werkzeug 1.0.0已删除不推荐使用的代码,包括所有werkzeug.contrib.您应该为新项目使用替代库. werkzeug.contrib.session被提取到安全cookie .

Werkzeug 1.0.0 has removed deprecated code, including all of werkzeug.contrib. You should use alternative libraries for new projects. werkzeug.contrib.session was extracted to secure-cookie.

如果您正在使用的现有项目需要contrib中的某些内容,则需要降级为Werkzeug< 1:

If an existing project you're using needs something from contrib, you'll need to downgrade to Werkzeug<1:

pip3 install Werkzeug<1

这篇关于当我执行Flask运行时,它显示错误:ModuleNotFoundError:没有名为"werkzeug.contrib"的模块.谁能帮我这个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 17:28