Python Virtual Environments with “virtualenv”

Python virtual environment allows python programmers to safely work with different python packages & different versions to test the application. Plus it would not impact the other python environments on the same system.

The following command will install the “virtualenv” in /usr/local/bin folder:

ssh -H python3 -m pip install virtualenv

The virtualenv is now available to all the applications/users on the system.

The following command installs the virtualenv in user’s local folder (~/.local/bin/):

python3 -m pip install virtualenv

Check the version of virtualenv:

python3 -m virtualenv --version

Create a virtual environment with the name “ve100” using the following command:

virtualenv ve100

The above command will create a folder with the name “ve100” at the current location.

Activate the following the virtual python environment using the following command:

source ve100/bin/activate

To deactivate, run the deactivate command:


To create a virtual environment with a desired version of python:

virtualenv -p /usr/bin/python2.7 ve200