flask_socketio import wont work, error: No module named flask_socketio
Asked Answered
M

3

5

Im trying to create connection between flask socketio and react native socketio, I have already prepared client side with react native socketio BUT I have run into problem with importing flask_socketio in rpi. Im trying to use simplest implementation possible, this is my code:

from flask import Flask
from flask_socketio import SocketIO, emit
 
app = Flask(__name__)
 
@app.route('/', methods=['GET'])
def hello_world():
    return "Hello World"
 
if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5005)

Without line 2 it works perfectly but I need to use flask_socketio. here is photo too(first run is without importing flask_socketio, than I tried to import it and it wont work. I have tried reinstalling flask_socketio twice, rebooting but nothing works:/enter image description here:

Maletta answered 27/10, 2020 at 17:25 Comment(0)
M
8

Problem was that I was installing it with sudo python pip install flask_socketio, BUT I had to use python3, so right installation is python3 -m pip install flask_socketio

Maletta answered 27/10, 2020 at 19:3 Comment(0)
E
1

You need to go to cmd prompt and use:

sudo -H pip3 install flask-socketio
Enrique answered 21/7, 2021 at 11:48 Comment(0)
G
-1

This might resolve your problem

socketio = SocketIO(app, cors_allowed_origins="*")

this will work on any version of socketio

Geest answered 7/6, 2021 at 23:13 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.