I can only assume you got the Werkzeug 3.0 update (as flask-login didn't up-bound their werkzeug dependency).

In their ongoing quest to remove all the non-core public APIs of werkzeug, the developers deprecated most of werkzeug.urls in Werkzeug 2.3 (released April 25th 2023), and removed it in Werkzeug 3.0 (released September 30th 2023).

Your options are:

  • force werkzeug to a pre-3.0 version

  • wait for flask-login to release a version compatible with werkzeug 3, a fix of that and a bunch of other stuff was merged a few minutes ago

    edit: flask-login 0.6.3 with the compatibility fix was released October 30th: https://github.com/maxcountryman/flask-login/releases/tag/0.6.3

Answer from Masklinn on Stack Overflow
Top answer
1 of 6
30

I can only assume you got the Werkzeug 3.0 update (as flask-login didn't up-bound their werkzeug dependency).

In their ongoing quest to remove all the non-core public APIs of werkzeug, the developers deprecated most of werkzeug.urls in Werkzeug 2.3 (released April 25th 2023), and removed it in Werkzeug 3.0 (released September 30th 2023).

Your options are:

  • force werkzeug to a pre-3.0 version

  • wait for flask-login to release a version compatible with werkzeug 3, a fix of that and a bunch of other stuff was merged a few minutes ago

    edit: flask-login 0.6.3 with the compatibility fix was released October 30th: https://github.com/maxcountryman/flask-login/releases/tag/0.6.3

2 of 6
9

The problem was as described by @Masklinn. I fixed the problem by changing the versions of werkzeug and flask in my requirements.py and reinstalling them.

My original requirements.txt:

bcrypt==4.0.1
blinker==1.6.2
click==8.1.7
dnspython==2.4.2
email-validator==2.0.0.post2
Flask==3.0.0
Flask-Bcrypt==1.0.1
Flask-Login==0.6.2
Flask-SQLAlchemy==3.1.1
Flask-WTF==1.2.0
greenlet==2.0.2
idna==3.4
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupSafe==2.1.3
SQLAlchemy==2.0.21
typing_extensions==4.8.0
Werkzeug==3.0.0
WTForms==3.0.1

My modified requirements.txt:

bcrypt==4.0.1
blinker==1.6.2
click==8.1.7
dnspython==2.4.2
email-validator==2.0.0.post2
Flask==2.3.0
Flask-Bcrypt==1.0.1
Flask-Login==0.6.2
Flask-SQLAlchemy==3.1.1
Flask-WTF==1.2.1
greenlet==2.0.2
idna==3.4
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupSafe==2.1.3
SQLAlchemy==2.0.21
typing_extensions==4.8.0
Werkzeug==2.3.0
WTForms==3.0.1
🌐
Reddit
reddit.com › r/flask › importerror: cannot import name 'url_decode' from 'werkzeug.urls' - flask web app issue
r/flask on Reddit: ImportError: cannot import name 'url_decode' from 'werkzeug.urls' - Flask Web App Issue
October 16, 2023 -

When i run my code using the run.py file i get this error:

Traceback (most recent call last):
  File "C:\Users\ivar\Desktop\Testing\flask-webchat\run.py", line 1, in <module>
    from app import app, socketio
  File "C:\Users\ivar\Desktop\Testing\flask-webchat\app\__init__.py", line 28, in <module>
    from .models import User
  File "C:\Users\ivar\Desktop\Testing\flask-webchat\app\models.py", line 3, in <module>
    from flask_login import UserMixin
  File "C:\Users\ivar\Desktop\Testing\flask-webchat\venv\Lib\site-packages\flask_login\__init__.py", line 12, in <module>
    from .login_manager import LoginManager
  File "C:\Users\ivar\Desktop\Testing\flask-webchat\venv\Lib\site-packages\flask_login\login_manager.py", line 33, in <module>
    from .utils import _create_identifier
  File "C:\Users\ivar\Desktop\Testing\flask-webchat\venv\Lib\site-packages\flask_login\utils.py", line 14, in <module>
    from werkzeug.urls import url_decode
ImportError: cannot import name 'url_decode' from 'werkzeug.urls' (C:\Users\ivar\Desktop\Testing\flask-webchat\venv\Lib\site-packages\werkzeug\urls.py)

The code & requirements.txt can be looked at or downloaded on github: https://github.com/ivarjt/flask-webchat/tree/feature/login-system

What I have tried so far:

Uninstalling and installing libraries mentioned in the error code.

Thanks in advance for any help!

Edit:

as u/ArabicLawrence said, the problem was that my flask-login version is incompatible with werkzeug.

pip install werkzeug==2.3.0

Discussions

ImportError: cannot import name 'url_decode' from 'werkzeug.urls' -> upgrade Flash-Login to 0.6.3+
After a pip upgrade I am getting (and have been getting in previous upgrades) the following error: ImportError: cannot import name 'url_decode' from 'werkzeug.urls' The reason this ... More on github.com
🌐 github.com
3
May 8, 2024
python - ImportError: cannot import name 'url_encode' from 'werkzeug' - Stack Overflow
I am currently running a conda environment with flask-wtf version 0.14.2 and wtforms version 2.21 and I have trouble solving this ImportError: cannot import name 'url_encode' from 'werkzeug' The More on stackoverflow.com
🌐 stackoverflow.com
loginmanager issue - cannot import name 'url_decode' from 'werkzeug.urls
I have python 3.11 running a venv with flask 3.0 and Werkzeug 3.0. However running from >>>flask_login import LoginManager i get from werkzeug.urls import url_decode ImportError: cannot import name 'url_decode' from 'werkzeug.urls' (/home/erver/venv/lib/python3.11/site-packages/werkzeug/urls.py) More on github.com
🌐 github.com
2
October 6, 2023
Werkzeug update to 3.0.0 breaks master branch builds
Traceback (most recent call last): ... _create_identifier File "/usr/local/lib/python3.10/dist-packages/flask_login/utils.py", line 14, in from werkzeug.urls import url_decode ImportError: cannot import name 'url_decode' from 'werkzeug.urls' (/usr/local/lib/python3.10/dist-pac... More on github.com
🌐 github.com
4
October 3, 2023
🌐
OpenPLC
openplc.discussion.community › post › cannot-import-name-urldecode-from-werkzeug-urls-pathtoopenplcv3-venvlibpython3-10sitepackageswerkzeugurls-py-12749551
cannot import name 'url_decode' from 'werkzeug.urls' (/path/to/OpenPLC_V3/.venv/lib/python3.10/site-packages/werkzeug/urls.py) - OpenPLC Forum
October 3, 2023 - Thiago, hello, It's me again 🙂 I think You have to know about it So... : cannot import name 'url_decode' from 'werkzeug.urls' (/path/to/OpenPLC_V3/.venv/lib/python3.10/site-packages/werkzeug/urls.py) This is syslog error while starting openplc systemd My version werkzeug 3.0.x, the reason: update/upgrade there are no 'erl_decode' and 'url_encode' functions And solution: 1. pip3 install --force-reinstall -v "werkzeug==2.3" 2. go to /path/to/OpenPLC_V3/.venv/lib/python3.10/site-packages/ and remove or change name of werkzeug dir 3. find location of reinstalled werkzeug (in my case: ~/.local/lib/python3.10/site-packages/werkzeug) 4. cp -r ~/.local/lib/python3.10/site-packages/werkzeug /path/to/OpenPLC_V3/.venv/lib/python3.10/site-packages/werkzeug 5. start openplc.service
🌐
Beautiful Soup
tedboy.github.io › flask › _modules › werkzeug › urls.html
werkzeug.urls — Flask API
:param limit: the content length of the URL data. Not necessary if a limited stream is provided. :param return_iterator: if set to `True` the `cls` argument is ignored and an iterator over all decoded pairs is returned """ from werkzeug.wsgi import make_chunk_iter if return_iterator: cls = lambda x: x elif cls is None: cls = MultiDict pair_iter = make_chunk_iter(stream, separator, limit) return cls(_url_decode_impl(pair_iter, charset, decode_keys, include_empty, errors)) def _url_decode_impl(pair_iter, charset, decode_keys, include_empty, errors): for pair in pair_iter: if not pair: continue s
🌐
GitHub
github.com › pgadmin-org › pgadmin4 › issues › 7459
ImportError: cannot import name 'url_decode' from 'werkzeug.urls' -> upgrade Flash-Login to 0.6.3+ · Issue #7459 · pgadmin-org/pgadmin4
May 8, 2024 - To fix this Flask-Login needs to be upgraded to 0.6.3 as from then Werkzeug 3.x if supported · pip install git+https://github.com/maxcountryman/flask-login.git helped me but it is version 0.7-dev so maybe you can try first pip install Flask-Login==0.6.3 · source: https://stackoverflow.com/questions/77215107/importerror-cannot-import-name-url-decode-from-werkzeug-urls
Author   pgadmin-org
🌐
pythontutorials
pythontutorials.net › blog › importerror-cannot-import-name-url-decode-from-werkzeug-urls
How to Fix ImportError: cannot import name 'url_decode' from 'werkzeug.urls' in Flask with flask-login — pythontutorials.net
Older versions of flask-login (e.g., versions < 0.5.0) explicitly used url_decode in their codebase. For example, in flask_login/utils.py, you might find: from werkzeug.urls import url_decode # This line breaks in Werkzeug >= 2.0.0
🌐
Ubuntu
bugs.launchpad.net › bugs › 2048769
Bug #2048769 “Adopt to new python-werkzeug 3.0 API” : Bugs : python-werkzeug package : Ubuntu
Python-werkzeug 3.0 was syncronized from Debian experimental. The 3.x track is not API compatible with the 2.x track: https://werkzeug.palletsprojects.com/en/3.0.x/urls/ https://werkzeug.palletsprojects.com/en/2.3.x/urls/ Especially the werkzeug.urls.url_decode method is gone, which leads to import failures like this: ==================================== ERRORS ==================================== _____________ ERROR collecting tests/consumer/storage/test_sqla.py _____________ ImportError ...
Find elsewhere
🌐
GitHub
github.com › pallets › werkzeug › issues › 2796
loginmanager issue - cannot import name 'url_decode' from 'werkzeug.urls · Issue #2796 · pallets/werkzeug
October 6, 2023 - I have python 3.11 running a venv with flask 3.0 and Werkzeug 3.0. However running from >>>flask_login import LoginManager i get from werkzeug.urls import url_decode ImportError: cannot import name 'url_decode' from 'werkzeug.urls' (/home/erver/venv/lib/python3.11/site-packages/werkzeug/urls.py)
Author   pallets
🌐
Miguel Grinberg
blog.miguelgrinberg.com › post › we-have-to-talk-about-flask
We Have To Talk About Flask - miguelgrinberg.com
>>> import flask_login Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/miguel/venv/lib/python3.12/site-packages/flask_login/__init__.py", line 12, in <module> from .login_manager import LoginManager File "/Users/miguel/venv/lib/python3.12/site-packages/flask_login/login_manager.py", line 33, in <module> from .utils import _create_identifier File "/Users/miguel/venv/lib/python3.12/site-packages/flask_login/utils.py", line 14, in <module> from werkzeug.urls import url_decode ImportError: cannot import name 'url_decode' from 'werkzeug.urls' (/Users/miguel/venv/lib/python3.12/site-packages/werkzeug/urls.py).
🌐
GitHub
github.com › janeczku › calibre-web › issues › 2904
Werkzeug update to 3.0.0 breaks master branch builds · Issue #2904 · janeczku/calibre-web
October 3, 2023 - Traceback (most recent call last): File "/app/calibre-web/cps.py", line 28, in <module> from cps.main import main File "/app/calibre-web/cps/__init__.py", line 29, in <module> from .MyLoginManager import MyLoginManager File "/app/calibre-web/cps/MyLoginManager.py", line 24, in <module> from flask_login import LoginManager, confirm_login File "/usr/local/lib/python3.10/dist-packages/flask_login/__init__.py", line 12, in <module> from .login_manager import LoginManager File "/usr/local/lib/python3.10/dist-packages/flask_login/login_manager.py", line 33, in <module> from .utils import _create_identifier File "/usr/local/lib/python3.10/dist-packages/flask_login/utils.py", line 14, in <module> from werkzeug.urls import url_decode ImportError: cannot import name 'url_decode' from 'werkzeug.urls' (/usr/local/lib/python3.10/dist-packages/werkzeug/urls.py)
Author   janeczku
🌐
HatchJS
hatchjs.com › home › 5 ways to fix the `cannot import name ‘url_decode’ from ‘werkzeug.urls’` error
5 Ways to Fix the `cannot import name 'url_decode' from 'werkzeug.urls'` Error
January 5, 2024 - The error “cannot import name ‘url_decode’ from ‘werkzeug.urls'” can also be caused by incorrect import statements. Make sure that you are importing the `url_decode` function from the `werkzeug.urls` module.
🌐
Odoo
odoo.com › forum › help-1 › getting-importerror-cannot-import-name-url-from-werkzeugurls-while-installing-odoo17-238903
Getting ImportError: cannot import name 'URL' from 'werkzeug.urls' while installing odoo17. | Odoo
December 6, 2023 - Hello! I'm getting import error while installing odoo17 community in my local system. File "/home/siddharth/odoo/odoo/odoo/ http.py [1] ", line 161, in from werkzeug.urls import URL, url_parse, url_encode, url_quote ImportError: cannot import name 'URL' from 'werkzeug.urls' (/home/siddharth/py3.12-env/lib/python3.12/site-packages/werkzeug/ urls.py [2] ) I tried to change versions of Werkzeug library and tried with lower Python versions also.
🌐
Beautiful Soup
tedboy.github.io › flask › generated › werkzeug.url_decode.html
werkzeug.url_decode — Flask API
werkzeug.url_decode(s, charset='utf-8', decode_keys=False, include_empty=True, errors='replace', separator='&', cls=None)[source]¶
🌐
YouTube
youtube.com › sophía wagner
ImportError: cannot import name 'url_decode' from 'werkzeug.urls' - YouTube
ImportError: cannot import name 'url_decode' from 'werkzeug.urls' Hey guys! Hopefully you found a solution that helped you! The Content is licensed under (ht...
Published   February 9, 2024
Views   39
🌐
GitHub
github.com › lss233 › chatgpt-mirai-qq-bot › issues › 1232
[BUG] cannot import name 'url_decode' from 'werkzeug.urls' · Issue #1232 · lss233/kirara-ai
October 19, 2023 - 2023-10-19 10:23:10.685 | ERROR | utils.exithooks:foo:35 - 看样子程序似乎没有正常退出。 2023-10-19 10:23:10.685 | ERROR | utils.exithooks:foo:36 - cannot import name 'url_deco de' from 'werkzeug.urls' (/root/chatgpt/myvenv/lib/python3.11/site-packages/werkzeug/urls. py) NoneType: None 2023-10-19 10:23:10.685 | ERROR | utils.exithooks:foo:37 - 你可以在这里阅读常见问题的解 决方案: 2023-10-19 10:23:10.685 | ERROR | utils.exithooks:foo:38 - https://github.com/lss233/ch atgpt-mirai-qq-bot/issues/85 Exception ignored in atexit callback: <function foo at 0x730df68400>
Author   lss233
🌐
GitHub
github.com › maxcountryman › flask-login › issues › 782
cannot import name 'url_decode' from 'werkzeug.urls' (no duplicates!!!) · Issue #782 · maxcountryman/flask-login
October 3, 2023 - After upgrading to Flask 3.0.0, the following imports no longer work in flask_login/utils.py: from werkzeug.urls import url_decode from werkzeug.urls import url_encode To Reproduce Steps to reprodu...
Author   maxcountryman
🌐
GitHub
github.com › jarun › buku › issues › 707
bukuserver bails with error from werkzeug.urls · Issue #707 · jarun/buku
January 7, 2024 - (env) ~$ bukuserver run help Traceback (most recent call last): File "/home/r0max/env/bin/bukuserver", line 5, in from bukuserver.server import cli File "/home/r0max/env/lib/python3.9/site-packages/bukuserver/server.py", line 11, in from flask_api import FlaskAPI, status File "/home/r0max/env/lib/python3.9/site-packages/flask_api/init.py", line 1, in from flask_api.app import FlaskAPI File "/home/r0max/env/lib/python3.9/site-packages/flask_api/app.py", line 10, in from flask_api.request import APIRequest File "/home/r0max/env/lib/python3.9/site-packages/flask_api/request.py", line 5, in from werkzeug.urls import url_decode_stream ImportError: cannot import name 'url_decode_stream' from 'werkzeug.urls' (/home/r0max/env/lib/python3.9/site-packages/werkzeug/urls.py)
Author   jarun