Set Up a Virtual Python Environment

The installation should happen in an isolated Python environment just for BYCEPS so that its requirements don’t clash with different versions of the same libraries somewhere else in the system.

Python already comes with the necessary tools, namely virtualenv and pip.

Change into the BYCEPS path and create a virtual environment (named “venv”) there:

$ cd byceps
$ python3 -m venv venv

Activate it (but don’t change into its path):

$ . ./venv/bin/activate

Note that the first dot is the dot command, followed by a relative file name (which is written as explicitly relative to the current path, ./).

Whenever you want to activate the virtual environment, make sure to do that either in the path in which you have created it using the above command, or adjust the path to reference it relatively (e.g. ../../venv/bin/activate) or absolutely (e.g. /var/www/byceps/venv/bin/activate).

Make sure the correct version of Python is used:

(venv)$ python -V
Python 3.9.2

It’s probably a good idea to update pip to the current version:

(venv)$ pip install --upgrade pip

Install the Python depdendencies via pip:

(venv)$ pip install -r requirements.txt

Install BYCEPS in editable mode to make import byceps work in scripts:

(venv)$ pip install -e .