. Advertisement .
. Advertisement .
Python has powerful high-level data structures and a simple yet effective approach to object-oriented programming. Python’s command syntax is a huge plus. Its clarity, ease of understanding, and flexible typing make it rapidly an ideal language for scripting and application development in various fields in most areas and all platforms. The following warning error may appear when you try to run the program: cannot import name ‘_endpoint_from_view_func’ from ‘flask.helpers’. This is a common error made by all coders. So, why does it happen, and how could it be resolved? We’ll talk about everything with you.
Why Does The Error ”Cannot import name ‘_endpoint_from_view_func’ from ‘flask.helpers’” in Python Occur?
When you run the code, something goes wrong in the line below.
from flask_restful import reqparse, Api, Resource
And the above error may occur like this.
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
Some Fundamental Methods For ”Cannot import name ‘_endpoint_from_view_func’ from ‘flask.helpers’” Error
And, you know what, you might be able to solve the above error with some simple ways. We can better understand these responses by using the cases below.
Method 1: Use as shown below
Because desperate times necessitate measures, here is a monkey patch we are not proud of, but it gets the job done while the merge isn’t in place: use as shown below.
import flask.scaffold flask.helpers._endpoint_from_view_func = flask.scaffold._endpoint_from_view_func import flask_restful
Method 2: Combine the change with a Flask version bump
This does not work with Flask2.0.0. Except for that effect, it’s worth a shot. Alternatively, you could combine the change with a Flask version bump.
Method 3: Here’s a monkey patching idea
In the meantime, here’s a monkey patching idea.
import flask.scaffold flask.helpers._endpoint_from_view_func = flask.scaffold._endpoint_from_view_func import flask_restful …
Method 4: Update the Flask-RESTful package version
Excepting the solutions mentioned above, there is another solution for you to resolve the error ” Cannot import name ‘_endpoint_from_view_func’ from ‘flask.helpers’ in Python”. It is updating the Flask-RESTful package version.
Your Flask-RESTful package is currently at version 0.3.8. Using pip show flask-restful, you may determine the version of flask-restful that is currently installed. Therefore, you simply update the Flask-RESTful package version since release 0.3.9 contains a fix for the current error. Let’s use the following command to do that:
The error alo can be solved if you use the new version of Flask-RESTful.
Some solutions mmentioned above are very simple, but they work perfectly. After using them, your error will completely disappear and your progrram wiill run well without any errors. So, what are you waiting without applying them for your error to get your desired results?
We believe that the above solutions will be beneficial to all readers.
The remedies presented above have been the most effective for individuals who are still perplexed by this error: ”Cannot import name ‘_endpoint_from_view_func’ from ‘flask.helpers’ in Python”. When you still seek help or have other questions, we have a big community where everybody is always willing to help you. Lastly, we hope all readers have a fantastic day with innovative code solutions.
→ How To Solve TypeError: ‘NonType’ Object Is Not Callable In Python
Leave a comment