Create Python Virtual Environment.


I’m using Ubuntu 20.04 server, I have XFCE installed.

What we’ll cover:

  1. Setup Python

Setup Python

sudo apt-get update && sudo apt-get upgrade
sudo apt install python3-pip python3-dev

Upgrade pip and install the package by typing:

sudo -H pip3 install --upgrade pip
sudo -H pip3 install virtualenv

Create a directory to put our virtual environment

mkdir ~/my_project_dir
cd ~/my_project_dir

Install python 3.6 into /usr/bin/python3.6

Create new virtualenv

virtualenv -p /usr/bin/python3.6/bin/python3.6 environment36
source environment36/bin/activate

python -V

python -V