How to create a python virtual environment in Linux

Install pip

sudo apt-get install python3-pip
# replace apt-get with dnf or zypper or whatever your distro uses

Install the python virtualenv package

pip3 install virtualenv

Make your main virtualenv directory

mkdir ~/.virtualenvs

Create the Virtual Environment

virtualenv --python=`which python3` ~/.virtualenvs/myvenv

Activate the virtual Environment with

source ~/.virtualenvs/myvenv/bin/activate

 

You may also like...

Leave a Reply