Ubuntu

Install PIP on Ubuntu 17.10

Install PIP on Ubuntu 17.10 Artful Aardvark

Python is a widely used general purpose programming language. Python is very programmer friendly and easy to learn. Python is a modular programming language. So people all over the world write python code to solve different problems and share these codes with other people who have the same problems. The repository where all of these are kept is called PyPi or Python Package Index. PIP is just a tool used to automatically install these packages from PyPi repository. A PyPi package may depend on other PyPi packages. PIP also resolves package dependencies. PIP can also install packages downloaded manually from PyPi. So basically PIP is the package manager of Python, just like apt is for Ubuntu. PIP is a very useful tool for Python programmers.

In this article, I will show you how to install the latest version of Python PIP on Ubuntu 17.10 Artful Aardvark. Let’s get started.

There are 2 versions of Python programming languages that are still widely used today. They are Python 2 and Python 3. Work is in progress to convert all Python 2 codes to Python 3. Once the conversion is complete, Python 3 will dominate and the days for Python 2 will be over. Since both of these versions of Python programming languages are still in use today, I will show you how to install and upgrade PIP on Python 2 and Python 3.


Installing PIP for Python 3:

On Ubuntu 17.10 Artful Aardvark, PIP is not installed by default. Python 3.6.3 is installed. So let’s install PIP for Python 3 first.

You can check the version of Python 3 that is installed on your Ubuntu operating system with the following command:

$ python3 --version

Before you try to install anything new on Ubuntu operating system, run the following command to update the package repository cache of Ubuntu:

$ sudo apt-get update


To install PIP for Python3 on Ubuntu 17.10, run the following command:

$ sudo apt-get install python3-pip

Now press ‘y’ and then press <Enter> to continue. It should take a while to download and install all these new packages depending on your internet connection.

Once the installation is complete, you can check the version of PIP for Python 3 using the following command:

$ pip3 --version

You can see that, the version of PIP installed I PIP 9.0.1. According to the official website of PIP, this is the latest version as of this writing.


Updating PIP for Python 3:

By the time you read this article, the version of PIP for Python 3 might change. I am going to show you how to update PIP for Python 3 now.

Open a terminal and run the following command to update PIP for Python 3:

$ pip3 install -U pip

As you can see PIP for Python 3 has been updated.

Now to check the version of PIP for Python 3, run the following command:

$ pip3 --version

You can see that it is 9.0.1 from the screenshot. Notice any difference? Before I updated PIP for Python 3, the command said PIP was installed in /usr/lib/python3/dist-packages directory. After I upgraded PIP for Python 3, the command now says that PIP is installed on the current user’s home directory. It means the upgrade was successful.


Install PIP for Python 2:

Python 2 is not installed by default on Ubuntu 17.10 Artful Aardvark. But if you do need Python 2 for any specific reason, you can install Python 2 on Ubuntu 17.10.

Run the following command to install Python 2 on Ubuntu 17.10:

$ sudo apt-get install python

Press ‘y’ and press <Enter> to continue the installation. It may take a while to download and install everything depending on your internet connection.

Once Python 2 is installed, you can check the version of Python 2 with the following command:

$ sudo python --version

You can see that the installed Python 2 version is 2.7.14.

Now to install PIP for Python 2, run the following command:

$ sudo apt-get install python-pip

Press ‘y’ and press <Enter> to continue the installation. It may take a while to download and install everything depending on your internet connection.

Once the installation is complete, you can check the version of PIP for Python 2 using the following command:

$ pip --version

You can see that the version of PIP for Python 2 installed is 9.0.1 and its installed in /usr/lib/python2.7/dist-packages system directory. When we update PIP for Python 2, the installed location will change as it did for PIP for Python 3.


Update PIP for Python 2:

To update PIP for Python 2, run the following command:

$ pip install -U pip

Now check the version of PIP for Python 2 with the following command:

$ pip --version

You can see that, the version of PIP for Python 2 is 9.0.1 and just like before the installed location is changed to the current user’s home directory. It verifies that the package update was successful.

So that’s how you install and update PIP for Python 2 and Python 3 on Ubuntu 17.10 Artful Aardvark. Thanks for reading this article.

About the author

Shahriar Shovon

Freelancer & Linux System Administrator. Also loves Web API development with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.