How to Install Pip on Ubuntu 16.10 Yakkety Yak

Python Logo

I am excited this evening. Why? Because I am finally getting back to some real Python development. While I have recently coded up some GIMP plug-ins, I haven’t really taken the time to properly set up my Python environment since making the switch from OS X to Ubuntu in December.  Now I’ve got some Django programming to do, but before I can start installing any third party packages, I’ll need to install pip, the de facto package management system for installing and managing Python packages. Think of pip being to Python as apt is to Ubuntu. The main repository for Python software is PyPi, the Python Package Index.

Before installing pip, we first want to make sure that our apt package indexes are up to date, so in a terminal session we run:

sudo apt-get update

Then for good measure we should make sure that all of our installed software is up to date:

sudo apt-get upgrade

Now we can finally get to installing pip. Ubuntu ships with both Python and Python 3 installed. Specifically, I have Python versions 2.7.12 and 3.5.2 installed. I haven’t paid attention to see if Python has been updated since I installed Yakkety Yak, but I can say with some degree of confidence that if you too are running 16.10, then you have some minor revision of 2.7 and 3.5 as well. Since these two branches of the language are separate beasts, and while I favor Python 3, I still do use both, so I want to install pip for both. The installation procedures for the two Python flavors are nearly identical, but I am going to outline them separately here anyway.

Install pip on Python 2.7

Once you update your package indexes and upgraded your software, installing pip is as simple as:

sudo apt-get install python-pip

This will download and install pip and all of it’s dependencies for use with Python 2.7. On my system, apt needed to install 12 new packages that took up an additional 45.6 MB of disk space. To verify that pip was properly installed and to see the version type:

pip -V

The output of that command for me is:

pip 8.1.2 from /usr/lib/python2.7/dist-packages (python 2.7)

The good news is that pip is properly installed. The bad news is that the latest stable version of pip is 9.0.1. It usually a good idea to run the most recent version of pip, so to upgrade my installation in my terminal session I type:

sudo pip install -U pip

Checking the version again tells me that the upgrade was successful:

pip 9.0.1 from /usr/local/lib/python2.7/dist-packages (python 2.7)

Install pip on Python 3.5

The installation of pip for Python 3.5 mirrors that of pip for 2.7 almost dead on. First we use apt-get to install pip and all of its dependencies:

sudo apt-get install python3-pip

This time 6 new packages weighing in at 55.8 MB need to be installed. Once apt has done its thing, we can verify the installation was successful by typing:

pip3 -V

Notice that the executable is now pip3 instead of pip. On my system this yields:

pip 8.1.2 from /usr/lib/python3/dist-packages (python 3.5)

Since we want to run the latest version of pip3 we then run:

sudo pip3 install -U pip

It’s worthwhile to note that while pip3 is the executable, the name of the package that we send as argument along with the upgrade option. Checking the installed version of pip3 a second, reassures us that the upgrade was successful.

pip 9.0.1 from /usr/local/lib/python3.5/dist-packages (python 3.5)

That’s all it takes to install the most recent version of pip for both Python 2.7 and Python 3.5. pip is an indispensable tool for managing Python packages, and someday I should write a more in depth post about the ins and outs of using pip, but right now I’m too excited about continuing to get Django set up. In the coming days, expect to see more articles from me about pip, Python, and Django. Until then, peace out!


1 comment

    • Mr A on February 10, 2017 at 8:44 pm
    • Reply

    Very well written with good explanation each sections. Direct – not verbose. GREAT WORK! Thank you

    Tested and 100%.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.