Python

This guide provides a walk-through of how to install the latest version of the Python along with the MQTT Client library.

Installing Python

This step is optional, you may skip to the Installing MQTT Client section.

Download and extract the latest version of Python 3:

cd /opt
sudo wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz
sudo tar xzf Python-3.8.0.tgz

Install the dependencies:

sudo apt-get install build-essential checkinstall
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev \
libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev

Run configure with optimizations and make install from the source:

This step may take up to 15min. depending on the model of the device.

cd Python-3.8.0
sudo ./configure --enable-optimizations
make altinstall

Update the link to the newly installed version of Python 3:

ln -s /usr/local/bin/python3.8 /usr/local/bin/python3

Restart your device in order to make sure Python 3 version is updated

Test your installation:

python3 --version
Python 3.8.0

Installing MQTT Client

This documentation uses Paho MQTT as a client library.

Make sure pip3 is installed before installing the library:

sudo apt-get -y install python3-pip
sudo apt-get update

Install the library by running the following command:

pip3 install paho-mqtt

Connect Device

Start connecting devices by following the guide :