When you have multiple Python applications, sometimes each application would require packages that specific to that project. In those cases we need virtual environments.

We will use in this post venv, which is part of the Python standard library. We create a virtual environment by running the following command in the project’s root directory:

python -m venv .venv

Then run the following command to make the virtual environment active:

source .venv/bin/activate

This virtual environment can then be used to install packages specific to the project that you are working on instead of using the global environment.