Skip to main content

Create Python Virtual Environment

· One min read
  1. Let’s start by installing the python3-venv package that provides the venv module.
sudo apt install python3-venv
  1. Once the module is installed we are ready to create virtual environments for Python 3.
  2. Switch to the directory where you would like to store your Python 3 virtual environments.
cd /path/to/your/project
  1. Within the directory run the following command to create your new virtual environment.
python3 -m venv venv
  1. The command above creates a directory called venv, which contains a copy of the Python binary, the Pip package manager, the standard Python library and other supporting files.
  2. To start using this virtual environment, you need to activate it by running the activate script.
source venv/bin/activate