Creating a virtual environment with PyPI - gecos-lab/PZero GitHub Wiki

Installation using PyPi

The first steps might be different depending on your operating system and on what software you have already installed.

If you already have a working development environment with Python, pip and venv you can create the virtual environment needed by PZero by running in a terminal (within the PZero folder):

python -m venv .venv
.venv\Scripts\activate
python -m pip install -r requirements.txt

This creates a new Python 3.12 virtual environment in the .venv sub-folder of the PZero folder, activates it, and install all the libraries listed in requirements.txt.

Once it has been set up in this way, the virtual environment can be activated with .venv\Scripts\activate, or from the IDE (e.g. PyCharm).

Note that .venv is already included in .gitignore, therefore its contents will not be uploaded to GitHub.

If you do not have a development with Python, pip and venv, you must set it up.

Windows

Here you need to download Python 3.12 from here and install it. Installing for all users is not necessary, but including the setup of the PATH environment variable seems to make things easier in later stages. PATH will typically include:

C:Users\<your user>\AppData\Local\Programs\Python\Python312\Scripts\
C:\Users\<your user>\AppData\Local\Programs\Python\Python312\
C:\Users\<your user>\AppData\Local\Programs\Python\Launcher\

Then you must run Python in a terminal, simply calling python or py to test that it works and show the release number, and install pip (if not already installed) with python -m ensurepip. For more advanced tasks, e.g. modifying a virtual environment, also pip-tools might be needed.

On Windows, you are now ready to create the virtual environment as discussed above.

Linux (Ubuntu or Debian)

First check if packages and dependencies need to be upgraded (routine check):

sudo apt update
sudo apt upgrade

Then check if python calls python 2 or python 3 with python --version. In general you need to type python3 to call python 3, but this can be modified if you have installed the python-is-python3 package.

Now you must install pip:

sudo apt install python3-pip

On Linux, you are now ready to create the virtual environment as discussed above.

macOS

On macOS, you might need to install a development environment before using Python and PyPi.

All the following commands must be entered in the macOS Terminal. First Homebrew, Python 3 (needed because the default Python on macOS is Python 2) and virtualenvwrapper are installed:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install python3
python3 -m ensurepip

On macOS, you are now ready to create the virtual environment as discussed above.

⚠️ **GitHub.com Fallback** ⚠️