{"id":254,"hash":"4de70104a4484cc7830392cabff86c83d065a23eccbaaac2b768d61c9d00e0c6","pattern":"Why did Flask start failing with &quot;ImportError: cannot import name &#39;url_quote&#39; from &#39;werkzeug.urls&#39;&quot;?","full_message":"Environment:\n\nPython 3.10.11\nFlask==2.2.2\n\nI run my Flask backend code in docker container, with BASE Image:\nFROM pytorch/pytorch:2.0.1-cuda11.7-cudnn8-runtime\n\nBut when I run the pytest with version pytest 7.4.2,\n\npip install pytest\npytest\n\nit raised an Error, with logs:\n\n==================================== ERRORS ====================================\n_____________ ERROR collecting tests/test_fiftyone_utils_utils.py ______________\nImportError while importing test module '/builds/kw/data-auto-analysis-toolkit-backend/tests/test_fiftyone_utils_utils.py'.\nHint: make sure your test modules/packages have valid Python names.\nTraceback:\n/opt/conda/lib/python3.10/importlib/__init__.py:126: in import_module\n    return _bootstrap._gcd_import(name[level:], package, level)\ntests/test_fiftyone_utils_utils.py:2: in <module>\n    import daat  # noqa: F401\n/opt/conda/lib/python3.10/site-packages/daat-1.0.0-py3.10.egg/daat/__init__.py:1: in <module>\n    from daat.app import app\n/opt/conda/lib/python3.10/site-packages/daat-1.0.0-py3.10.egg/daat/app/__init__.py:6: in <module>\n    from flask import Flask, jsonify, request\n/opt/conda/lib/python3.10/site-packages/flask/__init__.py:5: in <module>\n    from .app import Flask as Flask\n/opt/conda/lib/python3.10/site-packages/flask/app.py:30: in <module>\n    from werkzeug.urls import url_quote\nE   ImportError: cannot import name 'url_quote' from 'werkzeug.urls' (/opt/conda/lib/python3.10/site-packages/werkzeug/urls.py)\n\nMy codes works well when I directly run it with python run.py\n\nrun.py shown below\n\nfrom daat import app\n\napp.run(host='0.0.0.0')\n\nI guess it should be the pytest versions issue, because it used to work well without changing any related code, and I use pip install pytest without defined a specific version.\n\nAnd my backend runs well without pytest.","ecosystem":"pypi","package_name":"flask","package_version":null,"solution":"I had the same problem. 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.\n\nSolution: Just set a fix version for Werkzeug such as Werkzeug==2.2.2 in your requirements.txt and it should work.","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/77213053/why-did-flask-start-failing-with-importerror-cannot-import-name-url-quote-fr","votes":206,"created_at":"2026-04-19T04:41:39.771676+00:00","updated_at":"2026-04-19T04:52:04.238070+00:00"}