Create a Python 3.9 Virtual Environment Ubuntu

This post will show you how to create a Python 3.9 virtual environent using virtualenv on Ubuntu linux 20.04 machine.

Virtual Environment

Without getting into too many details allows us to create virtual environments that run a different version of Python. In our case, we will go through the process of creating a Python 3.9 environment.

Install Python 3.9

The first step in this process is to install the latest version of Python 3.9 and the development libraries.

sudo apt update
sudo apt install python3.9
sudo  apt-get install python3.9-dev python3.9-venv

Create and Activate Python 3.9 Virtual Environment

I will start with creating a Python 3.9 virtual environment called sandbox using the following command.

python3.9 -m venv sandbox

Once the environment has been created, it is ready to be activated, and if you notice to create it, I start the command with python3.9. To create a Python 3.8 virtual environment, I can run the same command with the needed version.

To activate the environment and start using it I will simply run the following command.

source sandbox/bin/activate

To exit the virtual environment I will type:


Success! You're on the list.





One response to “Create a Python 3.9 Virtual Environment Ubuntu”

  1. donald Avatar

    thanks so much