close

[Solved] cannot import name ‘_endpoint_from_view_func’ from ‘flask.helpers’ in python

Hello Guys, How are you all? Hope You all Are Fine. Today When I run the code, there is something wrong, and got this error cannot import name ‘_endpoint_from_view_func’ from ‘flask.helpers’ in python. So Here I am Explain to you all the possible solutions here.

Without Wasting your time, Lets start This Article to Solve This Error.

How cannot import name ‘_endpoint_from_view_func’ from ‘flask.helpers’ in python Error Occurs ?

When I run My code there is something wrong in below line.

from flask_restful import reqparse, Api, Resource

and error is

Exception has occurred: ImportError
cannot import name '_endpoint_from_view_func' from 'flask.helpers' (C:\Users\Min\AppData\Local\Programs\Python\Python37\lib\site-packages\flask\helpers.py)
  File "E:\yulin\python_project\image_text_project_-api\chuanxian_api_module_time_native2.py", line 24, in <module>
    from flask_restful import reqparse, Api, Resource

How To Solve cannot import name ‘_endpoint_from_view_func’ from ‘flask.helpers’ in python Error ?

Question: How To Solve cannot import name ‘_endpoint_from_view_func’ from ‘flask.helpers’ in python Error ?
Answer: Because desperate times call for desperate measures, here is a monkey patch I am not proud of, but gets the job done while the merge is not in place:

Solution 1

Because desperate times call for desperate measures, here is a monkey patch I am not proud of, but gets the job done while the merge is not in place: just use as like below.

import flask.scaffold
flask.helpers._endpoint_from_view_func = flask.scaffold._endpoint_from_view_func
import flask_restful

Solution 2

This is not compatible with Flask<2.0.0. Needs a try/except for that effect. Or you just roll the change together with bumping Flask version

Solution 3

In the meantime, I suggest a monkey patching:

import flask.scaffold
flask.helpers._endpoint_from_view_func = flask.scaffold._endpoint_from_view_func
import flask_restful
...

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?

Also Read

1 thought on “[Solved] cannot import name ‘_endpoint_from_view_func’ from ‘flask.helpers’ in python”

Leave a Comment