August 10, 2015

November 25, 2019

How to install pip, virtualenv and virtualenvwrapper on Linux

I don't know how much up-to-date is pip in repositories from other distributions but version in Ubuntu 15.04 is from about year ago.

sudo apt-get install python-pip
eshlox@eshlox:~$ pip -V
pip 1.5.6 from /usr/lib/python2.7/dist-packages (python 2.7)

Because of this some commands don't work correctly.

eshlox@eshlox:~$ pip freeze
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pip/", line 122, in main
status =, args)
File "/usr/lib/python2.7/dist-packages/pip/commands/", line 74, in run
req = pip.FrozenRequirement.from_dist(dist, dependency_links, find_tags=find_tags)
File "/usr/lib/python2.7/dist-packages/pip/", line 299, in from_dist
assert len(specs) == 1 and specs[0][0] == '=='
Storing debug log for failure in /home/eshlox/.pip/pip.log

Let's remove pip.

sudo apt-get remove python-pip

I think that better option would be to install current version of pip from official site. When it is possible I always prefer to install software in my user home directory, that's why --user flag appears below.

Let's install pip.

python --user

Check version.

eshlox@eshlox:~$ .local/bin/pip -V
pip 7.1.0 from /home/eshlox/.local/lib/python2.7/site-packages (python 2.7)

Pip is now installed in user home directory, executable file exists in ~/.local/bin. We should add this to \$PATH environment variable.

Edit ~/.bashrc file and add at the end:

export PATH=$PATH:$HOME/.local/bin

Reload configuration.

source .bashrc

Now we can just use pip in shell.

eshlox@eshlox:~$ pip -V
pip 7.1.0 from /home/eshlox/.local/lib/python2.7/site-packages (python 2.7)

We can simply upgrade pip when newer version will be available.

pip install pip --upgrade

In the same way we can install virtualenv and virtualenvwrapper.

pip install virtualenv virtualenvwrapper --user

Because we added ~/.local/bin to \$PATH, virtualenv and virtualenwrapper are available from command line.

eshlox@eshlox:~$ mkvirtualenv --version

As described here, we should add shell startup file with our path to virtualenwrapper (.bashrc). It can look like this:

export WORKON_HOME=$HOME/projects
export PROJECT_HOME=$HOME/projects
source $HOME/.local/bin/

Done. Everything works as it should, and we are not dependent on versions from system repository.

© 2020 Przemysław Kołodziejczyk