Search code examples
pythonflaskflask-socketio

flask_socketio import wont work, error: No module named flask_socketio


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:


Solution

  • 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