Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python - socketio import error

I installed python-socketio by this command :

sudo apt-get install python-socketio

But when I want to import it in my program, it has some error :

>>> from socketio import SocketIO
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    from socketio import SocketIO
ImportError: No module named 'socketio'

What is the problem and how can I solve it ?

like image 728
Majid Rahimpour Avatar asked Mar 06 '16 15:03

Majid Rahimpour


People also ask

What is Socket.IO in Python?

Socket.IO is a library that enables real-time, bidirectional and event-based communication between the browser and the server. It consists of: a Node. js server: Source | API. a Javascript client library for the browser (which can be also run from Node.

Can we use Socket.IO in Python?

While not comparable to eventlet and gevent in terms of performance, the Socket.IO server can also be configured to work with multi-threaded web servers that use standard Python threads. This is an ideal setup to use with development servers such as Werkzeug.

Can you use Socket.IO with Django?

Django socketio is a Django project that brings together a variety of features that allow you to use WebSockets seamlessly with any Django project. It is built on top of gevent-socketio which is a Python implementation of SocketIO protocol.

How do I check Python Socket.IO version?

You can check the socket.io version in node_modules->socket.io->package. json and there will be "version": "your version of socket.io".


2 Answers

If you want to install socketio you have to use pip.

I like to use python 3 so I use this command in Ubuntu.

sudo -H pip3 install python-socketio

If you want to use default python which is probably set as to python2 use.

sudo -H pip install python-socketio

Also if you type pip and then hit tab twice in a row it will show all the different version you have available. For example my output looks like this.

pip         pip2        pip2.7      pip3        pip3.5      pip-review
like image 107
Goddard Avatar answered Sep 29 '22 14:09

Goddard


The following code can be used ::

sudo apt update
sudo apt install python-socketio
like image 35
Akash Kandpal Avatar answered Sep 29 '22 14:09

Akash Kandpal