Create Python Virtual Environment.

Introduction

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

What we’ll cover:

  1. Setup Python

Setup Python

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

Upgrade pip and install the package by typing:

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

Create a directory to put our virtual environment

1
2
mkdir ~/my_project_dir
cd ~/my_project_dir

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

Create new virtualenv

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

python -V

1
python -V