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?

- 339
- 1
- 3
- 17
4 Answers
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

- 1,563
- 14
- 13
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.

- 65,299
- 14
- 133
- 152
-
Is there anyway to continue using SocketIO version 4, A flutter package only supports version 3 or 4 socketio server. https://pub.dev/packages/socket_io_client :: error- ```The client is using an unsupported version of the Socket.IO or Engine.IO protocols``` – kalaLokia Apr 21 '22 at 16:05
-
1Temporarily I manually installed package `Werkzeug` version below **2.1** to overcome this error. So that I can continue using `SocketIO` version `4.3.2`. – kalaLokia Apr 21 '22 at 17:15
-
The v3 and v4 versions are for the reference implementation in JavaScript, those versions are not related to versions of the Python server. The version mapping between JavaScript and Python are in the documentation: https://flask-socketio.readthedocs.io/en/latest/intro.html#version-compatibility – Miguel Grinberg Apr 21 '22 at 17:54
-
But using Flask-SocketIO version 5+ I get the unsupported version in client side error. Using Flask-SocketIO 4.3.2 I have no issues. – kalaLokia Apr 21 '22 at 17:59
-
After updating python package you also need to update version of socket.io in frontend (usually index.html), according to the link posted above by @MiguelGrinberg . Worth adding this into answer, otherwise it sounds like pip install solves the problem – Alleo Aug 05 '22 at 09:20
-
work for me after upgrade the version – Khaerul Umam Dec 01 '22 at 03:12
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

- 4,519
- 1
- 16
- 14
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

- 1,245
- 10
- 20