I ran the same code on Ubuntu with no problem, but ran it on Windows10 with problems. I also installed Flask. My windows environment is configured as follows:
$ pip --version
pip 21.1.1 from c:\users\min\appdata\local\programs\python\python37\lib\site-packages\pip (python 3.7)
$ pip show flask
Name: Flask
Version: 2.0.0
Summary: A simple framework for building complex web applications.
Home-page: https://palletsprojects.com/p/flask
Author: Armin Ronacher
Author-email: [email protected]
License: BSD-3-Clause
Location: c:\users\min\appdata\local\programs\python\python37\lib\site-packages
Requires: Werkzeug, itsdangerous, Jinja2, click
Required-by: Flask-RESTful, Flask-API
$ pip show flask-restful
Name: Flask-RESTful
Version: 0.3.8
Summary: Simple framework for creating REST APIs
Home-page: https://www.github.com/flask-restful/flask-restful/
Author: Twilio API Team
Author-email: [email protected]
License: BSD
Location: c:\users\min\appdata\local\programs\python\python37\lib\site-packages
Requires: Flask, aniso8601, six, pytz
Required-by:
When I run the code, there is wrong in
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
I don't know why, please help me, thank you very much.
That's a known issue that awaits to be solved here.
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
...
For reference, the current version of my Flask-RESTful
package is 0.3.8
.
Edit:
Since the issue has then been fixed in release 0.3.9
, just upgrade the package version:
Flask-RESTful>0.3.8
Like Renato mentioned, this is a known issue.
The team has fixed it.
Using a recent version of Flask-RESTful
fixed the issue for me.
For example:
Flask-RESTful==0.3.9
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With