之前一直用flask-restful写api,一切都是好好的,但是升级了flask2.0之后便再也无法启动了,一直报错
from flask.helpers import _endpoint_from_view_funcImportError: cannot import name '_endpoint_from_view_func' from 'flask.helpers'
查看源码发现2.0版的flask.helpers模块中已经找不到_endpoint_from_view_func方法了,查阅了各种资料发现flask2.0中将_endpoint_from_view_func方法修改到了flask.scaffold模块中,
于是乎只要在运行from flask_restful import Api前将flask.helpers._endpoint_from_view_func的引用做一下修改,就可以解决这个问题了。
import flask.scaffold
flask.helpers._endpoint_from_view_func = flask.scaffold._endpoint_from_view_func
将代码添加到from flask_restful import Api语句之前便可顺利启动。