miguelgrinberg / Flask-SocketIO

Socket.IO integration for Flask applications.
MIT License
5.37k stars 892 forks source link

ImportError: No module named exceptions #1278

Closed user563or9 closed 4 years ago

user563or9 commented 4 years ago

Hello, When I'm trying to import flask_socketio an ImportError is raising: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python27\lib\site-packages\flask_socketio\__init__.py", line 22, in <module> from socketio.exceptions import ConnectionRefusedError ImportError: No module named exceptions

I got the error after typing "import flask_socketio" from CMD.

Note: I tried to reinstall flask-socketio but it's still doesn't work. I'm using Python 2.7.12.

Do you have any idea to solve it?

miguelgrinberg commented 4 years ago

What's the output of the pip freeze command?

user563or9 commented 4 years ago

Hey, here is the output: appdirs==1.4.4 bcrypt==3.1.7 camera==1.3.0 certifi==2020.4.5.1 cffi==1.14.0 chardet==3.0.4 Click==7.0 cloudpickle==1.3.0 configparser==4.0.2 contextlib2==0.6.0.post1 cryptography==2.9.2 decorator==4.4.2 distlib==0.3.0 Django==1.11.29 dnspython==1.16.0 EasyProcess==0.2.10 entrypoint2==0.2 enum34==1.1.10 eventlet==0.25.2 fabric==2.5.0 filelock==3.0.12 Flask==1.1.1 Flask-Cors==3.0.8 Flask-SocketIO==4.3.0 greenlet==0.4.15 idna==2.9 image==1.5.31 importlib-metadata==1.6.0 importlib-resources==1.5.0 invoke==1.4.1 ipaddress==1.0.23 itsdangerous==1.1.0 Jinja2==2.11.1 MarkupSafe==1.1.1 monotonic==1.5 MouseInfo==0.1.2 netifaces==0.10.6 networkx==2.2 nmap==0.0.1 numpy==1.16.6 opencv-python==4.2.0.32 paramiko==2.7.1 pathlib2==2.3.5 Pillow==6.2.2 PyAutoGUI==0.9.48 pycparser==2.20 PyGetWindow==0.0.8 PyMsgBox==1.0.7 PyNaCl==1.3.0 pyperclip==1.7.0 PyRect==0.1.4 pyscreenshot==1.0 PyScreeze==0.1.26 python-engineio==3.12.1 python-nmap==0.6.1 python-socketio==4.5.1 PyTweening==1.0.3 pytz==2020.1 PyWavelets==1.0.3 pywin32==227 requests==2.23.0 scandir==1.10.0 scapy==2.4.2 scikit-image==0.14.5 scipy==1.2.3 singledispatch==3.4.0.3 six==1.14.0 socketio==0.2.1 typing==3.7.4.1 urllib3==1.25.9 virtualenv==20.0.20 Werkzeug==1.0.0 zipp==1.2.0

miguelgrinberg commented 4 years ago

Remove the package socketio. Don't know what that is, but it collides with python-socketio, which is the one you are trying to use.

user563or9 commented 4 years ago

I did, but now this error raised: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python27\lib\site-packages\flask_socketio\__init__.py", line 21, in <module> import socketio ImportError: No module named socketio

miguelgrinberg commented 4 years ago

Show me the pip freeze output again please.

user563or9 commented 4 years ago

appdirs==1.4.4 bcrypt==3.1.7 camera==1.3.0 certifi==2020.4.5.1 cffi==1.14.0 chardet==3.0.4 Click==7.0 cloudpickle==1.3.0 configparser==4.0.2 contextlib2==0.6.0.post1 cryptography==2.9.2 decorator==4.4.2 distlib==0.3.0 Django==1.11.29 dnspython==1.16.0 EasyProcess==0.2.10 entrypoint2==0.2 enum34==1.1.10 eventlet==0.25.2 fabric==2.5.0 filelock==3.0.12 Flask==1.1.1 Flask-Cors==3.0.8 Flask-SocketIO==4.3.0 greenlet==0.4.15 idna==2.9 image==1.5.31 importlib-metadata==1.6.0 importlib-resources==1.5.0 invoke==1.4.1 ipaddress==1.0.23 itsdangerous==1.1.0 Jinja2==2.11.1 MarkupSafe==1.1.1 monotonic==1.5 MouseInfo==0.1.2 netifaces==0.10.6 networkx==2.2 nmap==0.0.1 numpy==1.16.6 opencv-python==4.2.0.32 paramiko==2.7.1 pathlib2==2.3.5 Pillow==6.2.2 PyAutoGUI==0.9.48 pycparser==2.20 PyGetWindow==0.0.8 PyMsgBox==1.0.7 PyNaCl==1.3.0 pyperclip==1.7.0 PyRect==0.1.4 pyscreenshot==1.0 PyScreeze==0.1.26 python-engineio==3.12.1 python-nmap==0.6.1 python-socketio==4.5.1 PyTweening==1.0.3 pytz==2020.1 PyWavelets==1.0.3 pywin32==227 requests==2.23.0 scandir==1.10.0 scapy==2.4.2 scikit-image==0.14.5 scipy==1.2.3 singledispatch==3.4.0.3 six==1.14.0 typing==3.7.4.1 urllib3==1.25.9 virtualenv==20.0.20 Werkzeug==1.0.0 zipp==1.2.0

miguelgrinberg commented 4 years ago

Run this: pip install --upgrade flask-socketio python-socketio. I think this will fix your virtualenv.

user563or9 commented 4 years ago

I'm stiil getting the same error.

miguelgrinberg commented 4 years ago

Okay, try this one:

pip uninstall python-socketio

and then:

pip install python-socketio

user563or9 commented 4 years ago

I tried it before but now it’s finally worked! Thank you for the quick response.