Help with ModuleNotFoundError: No Module name socketio.exceptions on raspberry pi #2033
Unanswered
neastman018
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Try building a new virtual environment and reinstalling your dependencies. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am using socketio with flask in order to send data from python to a localhost host server however when I try to run the file I get the ModuleNotFoundError: No module named 'socketio.exceptions'. It works fine when I run it on my computer however not on the pi. I have tried using a virtual environment and that did not fix this issue. I have attempted all the previous solutions to this problem to no avail. Below is the code that I am trying to run and the error message.
`from flask import Flask, redirect, url_for, render_template, request
from flask_socketio import SocketIO
from threading import Lock
from datetime import datetime
from random import random
from alarm.alarm import play_alarm
import gspread
from oauth2client.service_account import ServiceAccountCredentials
"""
Background Thread
"""
thread = None
thread_lock = Lock()
app = Flask(name)
app.config['SECRET_KEY'] = 'gilead'
socketio = SocketIO(app, cors_allowed_origins='*')
#app.register_blueprint(second, url_prefix="")
#Google Sheets Validation Nonsense
scope =["https://spreadsheets.google.com/feeds",'https://www.googleapis.com/auth/spreadsheets',"https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/drive"]
creds = ServiceAccountCredentials.from_json_keyfile_name("C:/Users/neast/Documents/Susan/secret_key.json", scopes=scope)
client = gspread.authorize(creds)
sheet = client.open('Susan_Saint_Quotes').sheet1
def pickquote():
saint = round(random() * 2, 0)
quote = round(random() * 4, 0)
quote_picked = sheet.cell(quote+2, saint+1).value + ' - ' + sheet.cell(1, saint+1).value
return quote_picked
"""
In Background Thread loop whatever code you want to run continously. Then at the end have it emit the data you want
to send to the javascript.
"""
def background_thread():
alarm_active = False
quote_picked = pickquote()
while True:
now = datetime.now()
if now.second == 0:
quote_picked = pickquote()
@app.route('/')
def index():
return render_template("index.html")
"""
Decorator for connect
"""
@socketio.on('connect')
def connect():
global thread
print('Client connected')
"""
Decorator for disconnect
"""
@socketio.on('disconnect')
def disconnect():
print('Client disconnected', request.sid)
if name == "main":
socketio.run(app, debug=True, host='0.0.0.0', port=80)
`
and the error message:
Traceback (most recent call last):
File "/home/neast/SusannaTest/Susanna/server.py", line 2, in
from flask_socketio import SocketIO
File "/usr/lib/python3/dist-packages/flask_socketio/init.py", line 22, in
from socketio.exceptions import ConnectionRefusedError # noqa: F401
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'socketio.exceptions'
and this is what pip freeze in the virtual enviroment gives:
bidict==0.22.1
blinker==1.7.0
click==8.1.7
dnspython==2.4.2
eventlet==0.34.3
Flask==3.0.0
Flask-SocketIO==5.3.6
greenlet==3.0.3
h11==0.14.0
itsdangerous==2.1.2
Jinja2==3.1.3
MarkupSafe==2.1.3
python-engineio==4.8.2
python-socketio==5.11.0
simple-websocket==1.0.0
Werkzeug==3.0.1
wsproto==1.2.0
Thank you for any help.
Beta Was this translation helpful? Give feedback.
All reactions