环境:
引入flask_cache后运行时,出现以下错误
Traceback (most recent call last):
File "manager.py", line 5, in
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
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)
原因是新版本的flask插件已经不再使用 flask.ext.*
形式
修改/site-packages/flask_cache/jinja2ext.py
中from flask.ext.cache import make_template_fragment_key
为from flask_cache import make_template_fragment_key