Skip to content

ModuleNotFoundError: No module named 'flask.scaffold' #567

Closed
@tumluliu

Description

@tumluliu

Code

as from the official doc

from flask import Flask
from flask_restx import Resource, Api

app = Flask(__name__)
api = Api(app)

@api.route('/hello')
class HelloWorld(Resource):
    def get(self):
        return {'hello': 'world'}

if __name__ == '__main__':
    app.run(debug=True)

Repro Steps (if applicable)

  1. init a new python project with poetry with poetry new flask-restx-test
  2. enter the dir and poetry add flask-restx
  3. copy and paste the minimal API sample code into app.py
  4. enter the venv with poetry shell
  5. launch the app.py with python app.py

Expected Behavior

the app should be up and running

Actual Behavior

error

Error Messages/Stack Trace

error with:

Traceback (most recent call last):
  File "$HOME/.cache/pypoetry/virtualenvs/flask-restx-test-gvqPH5Xl-py3.10/lib/python3.10/site-packages/flask_restx/api.py", line 18, in <module>
    from flask.helpers import _endpoint_from_view_func
ImportError: cannot import name '_endpoint_from_view_func' from 'flask.helpers' ($HOME/.cache/pypoetry/virtualenvs/flask-restx-test-gvqPH5Xl-py3.10/lib/python3.10/site-packages/flask/helpers.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "$HOME/projects/flask-restx-test/app.py", line 2, in <module>
    from flask_restx import Resource, Api
  File "$HOME/.cache/pypoetry/virtualenvs/flask-restx-test-gvqPH5Xl-py3.10/lib/python3.10/site-packages/flask_restx/__init__.py", line 2, in <module>
    from .api import Api  # noqa
  File "$HOME/.cache/pypoetry/virtualenvs/flask-restx-test-gvqPH5Xl-py3.10/lib/python3.10/site-packages/flask_restx/api.py", line 20, in <module>
    from flask.scaffold import _endpoint_from_view_func
ModuleNotFoundError: No module named 'flask.scaffold'

Environment

  • Python version: 3.10.11
  • Flask version: 3.0.0
  • Flask-RESTX version: 1.1.0
  • Other installed Flask extensions: none

Additional Context

nothing else as this is the minimal sample. Could it be caused by some incompatibility?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions