docker / awesome-compose

Awesome Docker Compose samples
https://docs.docker.com/compose/
Creative Commons Zero v1.0 Universal
33.69k stars 6.49k forks source link

problem with werkzeug and flask in nginx-flask-mysql #423

Open iyad-obeid opened 6 months ago

iyad-obeid commented 6 months ago

There is some sort of version / dependency issue with Flask and Werkzeug:

cd nginx-flask-mysql
docker compose up

Crashes with the following trace, over and over:

nginx-flask-mysql-backend-1  | Traceback (most recent call last):
nginx-flask-mysql-backend-1  |   File "/usr/local/bin/flask", line 5, in <module>
nginx-flask-mysql-backend-1  |     from flask.cli import main
nginx-flask-mysql-backend-1  |   File "/usr/local/lib/python3.10/site-packages/flask/__init__.py", line 7, in <module>
nginx-flask-mysql-backend-1  |     from .app import Flask as Flask
nginx-flask-mysql-backend-1  |   File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 28, in <module>
nginx-flask-mysql-backend-1  |     from . import cli
nginx-flask-mysql-backend-1  |   File "/usr/local/lib/python3.10/site-packages/flask/cli.py", line 18, in <module>
nginx-flask-mysql-backend-1  |     from .helpers import get_debug_flag
nginx-flask-mysql-backend-1  |   File "/usr/local/lib/python3.10/site-packages/flask/helpers.py", line 16, in <module>
nginx-flask-mysql-backend-1  |     from werkzeug.urls import url_quote
nginx-flask-mysql-backend-1  | ImportError: cannot import name 'url_quote' from 'werkzeug.urls' (/usr/local/lib/python3.10/site-packages/werkzeug/urls.py)
nginx-flask-mysql-backend-1 exited with code 1
ElRapt commented 5 months ago

This is a version problem. I had the same. I haven't looked much into it to understand the real issue, however, I found that those two versions work together. :

Werkzeug==2.3.7
flask==2.2.2
iyad-obeid commented 5 months ago

That did the trick! You might consider making that change to the repo, it would be really helpful. Thanks!

Remi-Gau commented 2 months ago

bumping the flask version should work too

Flask==3.0.3
mysql-connector==2.2.9

More info here: https://stackoverflow.com/a/77214086

Gabrielfernandes7 commented 1 month ago

So, you can use libs without number version, like:

Flask
mysql-connector

In this way, you'd use the latest versionof the libraries.