ImportError: cannot import name ‘url_quote’ from ‘werkzeug.urls’

when you run your python app with flask and werkzeug packages, if the version do not match, it will through the following error:

ImportError: cannot import name 'url_quote' from 'werkzeug.urls'

 It is because Werkzeug 3.0.0 was released and Flask doesn’t specify the dependency correctly (requirements says Werkzeug>=2.2.0). This is why, Werkzeug 3.0.0 is still installed and Flask 2.2.2 isn’t made for Werkzeug 3.0.0.

to resolve this issue, just reinstall werkzeug with version 2.2.2 if your flask version is 2.0.x,

pip install werkzeug===2.2.2

or add werkzeug===2.2.2 in your requirements.txt file. or else upgrade the flask to a higher version

pip install --upgrade Flask


Leave a Reply

Your email address will not be published. Required fields are marked *