Setting werkzeug==0.16.1 in your requirements file fixes it. The issue is with the 1.0.0 version
Answer from PILA on Stack OverflowSetting werkzeug==0.16.1 in your requirements file fixes it. The issue is with the 1.0.0 version
guess the error is related to the new version of werkzeug. in new werkzeug version there is no "url_encode'. so try to install an older version of werkzeug like this : "pip install werkzeug==0.16.0" mine fixed with this solution
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
ImportError: cannot import name 'url_encode'
ImportError: cannot import name 'url_decode' from 'werkzeug.urls' -> upgrade Flash-Login to 0.6.3+
Getting ImportError: cannot import name 'URL' from 'werkzeug.urls' while installing odoo17.
Having troubles running app.py
I assume you have Werkzeug 3.0.0
try downgrading it to this version : 2.3
The core issue for this was with the flask-login package was incompatible with Flask/Werkzeug 3.0.0. This is now fixed in flask-login v0.6.3, that went live on 2023-10-31.
You need to update to latest package of flask-login and this is resolved.
https://github.com/maxcountryman/flask-login/releases/tag/0.6.3
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
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
It seemed to be a versioning error, the newer versions of the werkzeug package no longer have the url_encode that airflow is looking for, installing a lower version (pip install werkzeug==0.16.0) resolved the issue and airflow now runs without failing.
We have fixed it in Airflow 1.10.9, please install the latest version:
pip install -U apache-airflow
or pin Werkzeug by running pip install werkzeug<1.0