I prefer setting up virtualenv and virtualenvwrapper using pip rather than apt-get to ensure I am using the latest version and not relying on Ubuntu’s apt repositories to keep up. However, since I am installing pip from the repository, I have run into issues in the past when trying to upgrade pip and install virtualenv and virtualenvwrapper globally. I install almost all other packages into project specific virtual environments. This post is to remind myself of the proper steps, so hopefully you find it useful as well.
First update and install pip
for Python 3
sudo apt update && sudo apt install python3-pip
Now upgrade pip
to the latest version
sudo -H pip3 install --upgrade pip
Install virtualenv and virtualenvwrapper
sudo -H pip3 install virtualenv virtualenvwrapper
Configure .bashrc
echo "export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3" >> ~/.bashrc
echo "export WORKON_HOME=~/.virtualenv" >> ~/.bashrc
echo "source /usr/local/bin/virtualenvwrapper.sh" >> ~/.bashrc
And finally, activate virtualenvwrapper
source ~/.bashrc
Leave a Reply