This comprehensive Linux guide expects that you run the following commands as root user but if you decide to run the commands as a different user then ensure that the user has sudo access and that you precede each of the privileged commands with sudo

pip is a de facto standard package-management system used to install and manage software packages written in Python. Many packages can be found in the default source for packages and their dependencies — Python Package Index. Most distributions of Python come with pip preinstalled.

In this tutorial, we will guide you about how to install Python pip on your CentOS 7 system. Follow the instructions below.

Update Your Repository Cache

Before installing pip on your CentOS 7, you need to update your yum repository cache by running the following command

root@codesposts:~$ yum makecache

yum makecache
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.trouble-free.net
 * extras: mirror.trouble-free.net
 * updates: mirror.trouble-free.net
base                                                     | 3.6 kB     00:00     
extras                                                   | 3.4 kB     00:00     
updates                                                  | 3.4 kB     00:00     
(1/6): extras/7/x86_64/filelists_db                        | 249 kB   00:00     
(2/6): extras/7/x86_64/other_db                            | 131 kB   00:00     
(3/6): updates/7/x86_64/filelists_db                       | 5.2 MB   00:00     
(4/6): base/7/x86_64/filelists_db                          | 7.1 MB   00:00     
(5/6): base/7/x86_64/other_db                              | 2.6 MB   00:00     
(6/6): extras/7/x86_64/prestodelta                         |  73 kB   00:00 

Adding EPEL Repository

Now, add the EPEl repository to your CentOS by running the following command.

root@codesposts:~$ yum install epel-release

Installing pip

Now, run the following command to install Python pip on your system.

root@codesposts:~$ yum install python-pip

Verifying The Installation

You can verify the version of the pip installed on your system by running the following command.

root@codesposts:~$ pip --version

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

Installing Python3 pip

If you want to install the Python3 pip instead of the Python2 pip, you can run the command below

First, search for the latest version of pip3 package available by the following command

root@codesposts:~$ yum search pip | grep python3

python34-pip.noarch : A tool for installing and managing Python3 packages
python36-pip.noarch : A tool for installing and managing Python3 packages

As you can see that python36-pip is the latest version available, now run the following command

root@codesposts:~$ yum install python36-pip

Verifying The Version

Run the following command to verify the version of pip3 installed on your system.

root@codesposts:~$ pip3 --version

pip 8.1.2 from /usr/lib/python3.6/site-packages (python 3.6)

Installing Packages Using pip

To install a package using the pip, run the command like below

root@codesposts:~$ pip install twitter
OR
root@codesposts:~$ pip3 install twitter

Replace the “twitter” with the package name you want to install.

Displaying All Installed Packages

You can display the list of all the packages installed on your system using pip by running the command below

root@codesposts:~$ pip list

backports.ssl-match-hostname (3.5.0.1)
blivet (0.61.15.72)
Brlapi (0.6.0)
cffi (1.6.0)
chardet (2.2.1)
configobj (4.7.2)
configshell-fb (1.1.23)
coverage (3.6b3)
cryptography (1.7.2)
cupshelpers (1.0)
decorator (3.4.0)
di (0.3)
dnspython (1.12.0)
enum34 (1.0.4)
ethtool (0.8)
firstboot (19.5)
fros (1.0)
futures (3.1.1)
gssapi (1.2.0)
idna (2.4)

Removing A Package

If you want to remove a package, you can run the command below

root@codesposts:~$ pip uninstall twitter

Replace the “twitter” with the package name you want to install.