p1ngul1n0/blackbird

ImportError: cannot import name 'url_quote' (workaround)

Closed this issue · 0 comments

Building a fresh Docker image from this Repository code today would lead into the following error:

...
    from flask import Flask, Response, render_template, request, jsonify, send_file
  File "/usr/local/lib/python3.8/dist-packages/flask/__init__.py", line 7, in <module>
    from .app import Flask as Flask
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 27, in <module>
    from . import cli
  File "/usr/local/lib/python3.8/dist-packages/flask/cli.py", line 17, in <module>
    from .helpers import get_debug_flag
  File "/usr/local/lib/python3.8/dist-packages/flask/helpers.py", line 14, in <module>
    from werkzeug.urls import url_quote
ImportError: cannot import name 'url_quote' from 'werkzeug.urls' (/usr/local/lib/python3.8/dist-packages/werkzeug/urls.py)

This is not a bug of this code but one of Flask and Werzeug. The former does not specifiy the requirements correctly so that Werkzeug 3.0.0 and Flasks code is not ready for this yet (see SO answer here).

Solution:

Change this

pip install -r requirements.txt

to this

pip install -r requirements.txt && pip install Werkzeug==2.2.2

I would recommend to add this in the README until this is fixed.