Tutorial: Python Virtual Environment Wrapper


Step 1: Make sure the “virtualenv” is already installed

virtualenv --version

Step 2: Install “virtualenvwrapper

sudo -H python3 -m pip install virtualenvwrapper

Step 3: Add some environment variables

Add the following at your .bash_profile file (or to your shell’s profile file)

export WORKON_HOME="$HOME/my_python_venvs"
export VIRTUALENVWRAPPER_VIRTUALENV="/usr/local/bin/virtualenv"
export VIRTUALENVWRAPPER_PYTHON="/usr/bin/python3"

export PROJECT_HOME="$HOME/my_python_projects"

Step 4: Source the wrapper script

 source /usr/local/bin/virtualenvwrapper.sh

Step 5: Create directories

mkdir $HOME/my_python_venvs
mkdir $HOME/my_python_projects

You are ready to use the virtualenvwrapper!!

Using virtualenvwrapper