Error : `ModuleNotFoundError: No module named 'flask.scaffold'`
Schefflera-Arboricola opened this issue · comments
Description
I was getting the following error and I wanted some help because I was able to host the website locally using docker 3 months ago and I didn't make any major changes since. Could you please refer/guide me on how I should approach debugging this?
Project repo : https://github.com/Schefflera-Arboricola/Grocery-Store
Error
(base) aditi@Aditis-MacBook-Air Grocery-Store % docker-compose up --build
[+] Building 46.1s (10/10) FINISHED
=> [app internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 611B 0.0s
=> [app internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [app internal] load metadata for docker.io/library/python:3.9 1.2s
=> [app 1/5] FROM docker.io/library/python:3.9@sha256:f2f14d6dabcbc113512050906474d44cdb2a1139fa26d9b05bef0eedb36ac94a 0.0s
=> [app internal] load build context 0.0s
=> => transferring context: 7.55kB 0.0s
=> CACHED [app 2/5] WORKDIR /app 0.0s
=> CACHED [app 3/5] COPY requirements.txt requirements.txt 0.0s
=> [app 4/5] RUN pip install -r requirements.txt 42.2s
=> [app 5/5] COPY . /app 0.2s
=> [app] exporting to image 2.3s
=> => exporting layers 2.3s
=> => writing image sha256:71dcbeff2e969013a640c51fe7ca7b920aeb05df5a82142473b2fe0ff898c1be 0.0s
=> => naming to docker.io/library/grocery-store-app 0.0s
[+] Running 1/1
✔ Container grocery-store-app-1 Recreated 0.1s
Attaching to grocery-store-app-1
grocery-store-app-1 | Traceback (most recent call last):
grocery-store-app-1 | File "/usr/local/lib/python3.9/site-packages/flask_restx/api.py", line 18, in <module>
grocery-store-app-1 | from flask.helpers import _endpoint_from_view_func
grocery-store-app-1 | ImportError: cannot import name '_endpoint_from_view_func' from 'flask.helpers' (/usr/local/lib/python3.9/site-packages/flask/helpers.py)
grocery-store-app-1 |
grocery-store-app-1 | During handling of the above exception, another exception occurred:
grocery-store-app-1 |
grocery-store-app-1 | Traceback (most recent call last):
grocery-store-app-1 | File "/app/main.py", line 3, in <module>
grocery-store-app-1 |
grocery-store-app-1 | from flask_restx import Api
grocery-store-app-1 | File "/usr/local/lib/python3.9/site-packages/flask_restx/__init__.py", line 2, in <module>
grocery-store-app-1 | from .api import Api # noqa
grocery-store-app-1 | File "/usr/local/lib/python3.9/site-packages/flask_restx/api.py", line 20, in <module>
grocery-store-app-1 | from flask.scaffold import _endpoint_from_view_func
grocery-store-app-1 | ModuleNotFoundError: No module named 'flask.scaffold'
grocery-store-app-1 exited with code 1
Additional context
Thank you :)
The issue is caused by incompatibility currently between flask>=3.0.0
and flask-restx
, see #566
Either downgrade to flask<3.0.0
or use flask-restx==1.2.0
which introduced a dependency to prevent this from happening.
That being said, I've hopefully got a bit of spare time this week to get everything merged and make flask-restx
compatible again!
Thanks @peter-doggart! It worked!