I am getting the following error when I try to run the backend of my web application: ImportError: cannot import name 'run_with_reloader' from 'werkzeug.serving'
. It is coming from within the \lib\site-packages\werkzeug\serving.py file. I think it has to do with the line from flask_socketio import SocketIO
inside my server file. Any ideas?
I had to downgrade Werkzeug
and Flask
to avoid this error. When Flask-SocketIO
is involved, you may need to stick with older versions to avoid incompatibility issues with newer versions of Flask
.
The combination that works for me is:
Flask-SocketIO==4.3.1
python-engineio==3.13.2
python-socketio==4.6.0
Flask==2.0.3
Werkzeug==2.0.3
This error has been addressed, so you are very likely using an old version of Flask-SocketIO. Once you upgrade the error should go away.
Werkzeug
version below 2.1 to overcome this error. So that I can continue using SocketIO
version 4.3.2
. –
Giroux I needed to keep using flask-socketio v4 (for older socketio.js) and pinning to 2.0.x version of Werkzeug fixed this problem
--- a/python-flask-socketio-server/requirements.txt
+++ b/python-flask-socketio-server/requirements.txt
@@ -1,4 +1,5 @@
flask
+Werkzeug==2.0.1
flask-socketio==4.3.2
# wheel should not be needed, but avoids pyyaml paho-mqtt bdist_wheel error
wheel
Note: I also needed to tell pip to not use cached packages, or else it would still pull in problematic 2.1.x version to virtualenv that was being regenerated.
pip install --no-cache-dir -r requirements.txt
Solution is to install the following Werkzeug version (Werkzeug-0.10.2.dev0dev-20220510) along with the following versions: [Tested in MacOS]
pip3 install Flask-SocketIO==4.3.1
pip3 install python-engineio==3.13.2
pip3 install python-socketio==4.6.0
pip3 install git+https://github.com/untitaker/werkzeug.git@reloader-perf
© 2022 - 2025 — McMap. All rights reserved.
The client is using an unsupported version of the Socket.IO or Engine.IO protocols
– Giroux