Create a virtual environment using a new version of Python
Install the version e.g. Python version 3.9:
1
2
3
4
sudo apt update
# sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.9
Install the development libraries
1
sudo apt-get install python3.9-dev python3.9-venv
Specify Python version when creating a virtual environment
1
2
3
4
virtualenv --python=/usr/bin/python3.9 env
# or
# python3.9 -m venv env
This post is licensed under CC BY 4.0 by the author.