How Do You Install and Create a Virtual Environment?

Problem scenario
You want to use a virtual environment to install pip packages. You want to run a Python program with a module that will require a pip installation. What should you do to install and configure the environment and then enter it using Ubuntu/Debian Linux?

Solution

sudo apt -y install python3-virtualenv
sudo apt -y install python3.*-venv
python3 -m venv cont_int #replace "cont_int" with the name of the directory you want to create
cd cont_int
source bin/activate

Leave a comment

Your email address will not be published. Required fields are marked *