This is a summary guide on how to setup virtual environments for Python using virtualenv
and virtualenvwrapper
. A couple of good references are:
sudo apt install python-pip
Note: if installed without sudo
, pip
will install under ~/.local/
sudo pip install virtualenv
Note: if installed without sudo
, pip
will install under ~/.local/
sudo pip install virtualenvwrapper
Note: you may change the directory of the virtual environments from ~/.virtualenvs
to something else
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
source ~/.bashrc
mkvirtualenv name-of-virtualenv
: make new virtual environmentworkon name-of-virtualenv
: start session within virtual environmentdeactivate name-of-virtualenv
: end sessionrm -r $WORKON_HOME/name-of-virtualenv
: remove virtual environment
For example, to explicitly specify Python 3:
mkvirtualenv --python=`which python3` name-of-virtualenv