ZeroMQ is a distributed messaging system where a programmer of any level of expertise can easily connect their code across languages and platforms. Recently I had a need to connect multiple nodes on one of my projects and researched around until I found ZeroMQ. I took a quick glance on the Learn the Basics page and saw how easy it is to implement it myself and any of my team members to implement it.
In fact, the most difficult part with using ZeroMQ was the installation process and getting it to work with Python. PyZMQ is the Python binding for ZeroMQ, but I found the installation procedures a bit confusing and thought that I would give my own way of installing ZeroMQ and PyZMQ on Ubuntu.
This is assuming that you are installing on a new installation of Ubuntu. Some dependencies may already be installed if you are using a system that is already setup.
1 |
sudo apt-get install git htop build-essential libtool pkg-config autoconf uuid-dev |
After installing some basic dependencies, we need to install libsodium. The following command lines are the way to install libsodium from source.
1 2 3 4 5 |
git clone https://github.com/jedisct1/libsodium.git cd libsodium ./autogen.sh ./configure make && make check && sudo make install |
Now, we can finally install ZeroMQ!
1 2 3 4 |
git clone https://github.com/zeromq/libzmq wget http://download.zeromq.org/zeromq-4.1.4.tar.gz ./autogen.sh && ./configure && make -j 4 make check && make install && sudo ldconfig |
Finally, on with PyZMQ, the Python binding for ZeroMQ.
1 2 |
sudo apt-get install python-zmq sudo ldconfig |
Now, to test that PyZMQ was correctly installed, try:
1 |
import zmq |
If no errors show up, you are ready to go!
Since ZeroMQ and PyZMQ are constantly updated, I will try to keep this post updated with every major version.