Python Config

If you are running multiple projects on your machine you may at this point want to set up a virtual python environment. The key advantage of a venv is that project libraries are kept separate from the system and other projects.

Setting up a VENV

Open a terminal or SSH window.

Create a folder for your project

mkdir HiveSci

Navigate to the project folder

cd HiveSci

Create the virtual environment

python -m venv ./venv

Activate the virtual environment

source ./venv/bin/activate


We can now install and/or upgrade all the Python packages we require.

Set Up Tools makes it easier for us to install complex modules with C Libs. Current version is 62.2.3 (June 2022) and as the package is installed as standard we upgrade.

pip install setuptools --upgrade

ConfigObj allows us to have an easy to work with configuration file.

pip install configobj

Paho MQTT is the Python library that will allow us to subscribe to the MQTT transmissions from the node.

pip install paho-mqtt 

Numpy is a fundamental package for Python arrays and is needed by Pandas.

pip install opencv-python
pip install numpy

Pandas provides us with data structures, time series and powerful data statistics and analysis tools.

pip install pandas

MatPlotLib is a plotting package that we can use to visualise our data.

pip install matplotlib
sudo apt-get install libatlas-base-dev

Flask provides us with a web application framework to display our data with

pip install flask

Requests is a HTTP Library. Probably not required.

pip install requests

Finding System Libraries.

We need to add the local include folder to the Python Path. This is relevant when operating inside a venv and maybe outside. Using:

import sys

We see that the venv site-packages folder is /home/<username>/HiveSci/venv/lib/python3.9/site-packages. Inside this location we will create a simple file with the name hivesci.pth and add the following single line.


Your Pi should now be ready for the Hive Scientia software. We would advise starting with the Hub Setup as this can be tested external to the Subscriber/Client.


Leave a Reply

Your email address will not be published. Required fields are marked *