引入flask_cache时出现ModuleNotFoundError: No module named 'flask.ext'
环境:
- centos 7.3
- python 3.6
- flask 1.0.2
- flask-cache 0.13.1
引入flask_cache后运行时,出现以下错误
Traceback (most recent call last):
File "manager.py", line 5, in <module>
app = create_app('pro')
File "./app/__init__.py", line 18, in create_app
cache.init_app(app, config=cache_config)
File "/prj/pro/x.groooo.com/.venv/lib/python3.6/site-packages/flask_cache/__init__.py", line 156, in init_app
from .jinja2ext import CacheExtension, JINJA_CACHE_ATTR_NAME
File "/prj/pro/x.groooo.com/.venv/lib/python3.6/site-packages/flask_cache/jinja2ext.py", line 33, in <module>
from flask.ext.cache import make_template_fragment_key
ModuleNotFoundError: No module named 'flask.ext'
unable to load app 0 (mountpoint='') (callable not found or import error)
修改/site-packages/flask_cache/jinja2ext.py
中
from flask.ext.cache import make_template_fragment_key
为
from flask_cache import make_template_fragment_key
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步