报错信息:
[root@ynlink-02 ynlink-api]# flask run
* Serving Flask app "main.py"
* Environment: development
* Debug mode: off
Usage: flask run [OPTIONS]
Error: While importing "main", an ImportError was raised:
Traceback (most recent call last):
File "/usr/local/python3/lib/python3.7/site-packages/flask/cli.py", line 240, in locate_app
__import__(module_name)
File "/home/microService/ynlink-api/main.py", line 54, in <module>
app = create_app()
File "/home/microService/ynlink-api/main.py", line 29, in create_app
cache.init_app(app)
File "/usr/local/python3/lib/python3.7/site-packages/flask_cache/__init__.py", line 156, in init_app
from .jinja2ext import CacheExtension, JINJA_CACHE_ATTR_NAME
File "/usr/local/python3/lib/python3.7/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'
处理方法:
vi /usr/local/python3/lib/python3.7/site-packages/flask_cache/jinja2ext.py
33行代码
from flask.ext.cache import make_template_fragment_key
修改为
from flask_cache import make_template_fragment_key