Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

212
Views
no se puede importar el nombre '_endpoint_from_view_func' de 'flask.helpers' en python

Ejecuté el mismo código en Ubuntu sin problemas, pero lo ejecuté en Windows10 con problemas. También instalé Flask. Mi entorno de Windows está configurado de la siguiente manera:

 $ 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: armin.ronacher@active-4.com 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: help@twilio.com License: BSD Location: c:\users\min\appdata\local\programs\python\python37\lib\site-packages Requires: Flask, aniso8601, six, pytz Required-by:

Cuando ejecuto el código, hay un error en

 from flask_restful import reqparse, Api, Resource

y el error es

 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

No se por que, por favor ayudame, muchas gracias.

over 4 years ago · Santiago Trujillo
4 answers
Answer question

0

Ese es un problema conocido que espera ser resuelto aquí .

Mientras tanto, sugiero un parche de mono:

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

Como referencia, la versión actual de mi paquete Flask-RESTful es 0.3.8 .


Editar :

Dado que el problema se solucionó en la versión 0.3.9 , simplemente actualice la versión del paquete:

 Flask-RESTful>0.3.8
over 4 years ago · Santiago Trujillo Report

0

Aquí hay un parche de mono. Puede definir su propio _endpoint_from_view_func o usar flask.scaffold._endpoint_from_view_func como se menciona en la respuesta de @RenatoDamas

 # monkey.py def _endpoint_from_view_func(view_func): """Internal helper that returns the default endpoint for a given function. This always is the function name. """ assert view_func is not None, "expected view func if endpoint is not provided." return view_func.__name__ # noinspection SpellCheckingInspection def patch_restx(endpoint_from_view_func: bool = True) -> None: """ Nasty hacks are here :param endpoint_from_view_func: Add missing function into flask for backward compatibility with `flask-restx` """ if endpoint_from_view_func: func_name = "_endpoint_from_view_func" try: import pkg_resources packages = pkg_resources.working_set.by_key if "flask" in packages and "flask-restx" in packages: flask_version = tuple(map(int, packages["flask"].version.split("."))) flask_restx_version = tuple(map(int, packages["flask-restx"].version.split("."))) if (2, 0, 0) <= flask_version and (1, 0, 0) > flask_restx_version: import flask if not hasattr(flask.helpers, func_name): setattr(flask.helpers, func_name, _endpoint_from_view_func) except ImportError: print(f"skipping monkey patch of {func_name}")
over 4 years ago · Santiago Trujillo Report

0

Como mencionó Renato, este es un problema conocido. El equipo lo ha solucionado. El uso de una versión reciente de Flask-RESTful me solucionó el problema. Por ejemplo:

 Flask-RESTful==0.3.9
over 4 years ago · Santiago Trujillo Report

0

Tuve un problema similar que acabo de resolver (o sigo tratando de resolver) aquí . Lo gracioso es que no puedo ejecutar mi servidor sin esa solución "monkey", incluso con mi matraz_restful comenzando en 0.3.9. No estoy seguro de cuál es el problema, aunque gracias por este hilo.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!