Reading Time: 5 minutes

Pip (also known as Pip3 — corresponding to Python 3) is a tool for installing and managing Python packages (the name "Pip" is a recursive anagram for "Pip Installs Packages"). It is considered by many to be essential for developing Python packages. If you're developing or distributing Python packages, Pip is a must-have. In this guide, you will be shown a few methods for installing Pip, as well as a few steps you can take to verify the installation was successful, giving you a smooth start to Python 3 package development. Let's review how to install Pip on CentOS 7.

Python is a programming language that has a design philosophy that emphasizes code readability. It is widely considered to be a very easy programming language to master because of that focus on readability. Python is open source, and will run a multitude of platforms including, but not limited to various Linux/UNIX distributions (CentOS, Ubuntu, Fedora, Debian, etc.), Microsoft Windows, and Mac OS X. This article only discusses an install on Pip on CentOS 7.

How to Install Pip on CentOS 7

Prerequisites

  • This article will guide the reader through steps used to install Pip on CentOS 7.
  • The steps below are shown with root access on a Core Managed CentOS 7 VPS from Liquid Web.
  • You will use any one of the options that follow.

Get 75% off a VPS!

Step 1: Add the EPEL Repository

The Extra Packages for Enterprise Linux (EPEL) repository is already included on many CentOS 7 servers. Since Pip is included in the standard EPEL repository, having it installed should ensure Pip is installed on CentOS 7 successfully:

sudo yum install epel-release

Answer "y" when prompted to continue.

Step 2: The Installation

Option 1: Install Pip on CentOS 7 with Yum

Before running any installations with Yum, it’s recommended that existing packages be updated:

sudo yum -y update

Now that existing packages have been updated, you can install python-pip and any required dependencies:

yum -y install python-pip

If you see something like the following, that means Pip was previously installed:

Setting up Install Process 
Package python-pip-7.1.0-1.el6.noarch already installed and latest version 
Nothing to do

Otherwise, you’ll see something like the following:

yum -y install python-pip
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.us.oneandone.net
 * extras: mirror.trouble-free.net
 * updates: centos.mirrors.tds.net
Resolving Dependencies
--> Running transaction check
---> Package python2-pip.noarch 0:8.1.2-8.el7 will be installed
--> Processing Dependency: python-setuptools for package: python2-pip-8.1.2-8.el7.noarch
--> Running transaction check
---> Package python-setuptools.noarch 0:0.9.8-7.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================
 Package           Arch       Version          Repository     Size
===================================================================
Installing:
 python2-pip       noarch     8.1.2-8.el7      base           1.5 M
Installing for dependencies:
 python-setuptools noarch     0.9.8-7.el7      base           396 k

Transaction Summary
===================================================================
Install  1 Package (+1 Dependent package)

Total download size: 1.9 M
Installed size: 7.7 M
Downloading packages:
(1/2): python-setuptools-0.9.8-7.el7.noarch.rpm | 396 kB  00:00     
(2/2): python2-pip-8.1.2-8.el7.noarch.rpm       | 1.5 MB  00:00     
---------------------------------------------------------------
Total                                  2.9 MB/s | 1.9 MB  00:00     

Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : python-setuptools-0.9.8-7.el7.noarch  1/2 
  Installing : python2-pip-8.1.2-8.el7.noarch        2/2 
  Verifying  : python2-pip-8.1.2-8.el7.noarch        1/2 
  Verifying  : python-setuptools-0.9.8-7.el7.noarch  2/2 

Installed:
  python2-pip.noarch 0:8.1.2-8.el7                                                

Dependency Installed:
  python-setuptools.noarch 0:0.9.8-7.el7                                           

Complete!

Option 2: Install Pip on CentOS 7 with Curl and Python

You can also use cURL to download and use Python to install Pip on CentOS 7:

curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"

Once you’ve downloaded the install script, you can run it with the following command:

python get-pip.py

Your output will vary, but it should look something like the output shown below:

python get-pip.py
Collecting pip
  Downloading https://files.pythonhosted.org/packages/fe/ef/60d7ba03b5c442309ef42e
7d69959f73aacccd0d86008362a681c4698e83/pip-21.1.3-py3-none-any.whl (1.5MB)
    100% |████████████████████████████████| 1.5MB 1.2MB/s 
Collecting wheel
  Downloading https://files.pythonhosted.org/packages/65/63/39d04c74222770ed1589c0e
aba06c05891801219272420b40311cd60c880/wheel-0.36.2-py2.py3-none-any.whl
Installing collected packages: pip, wheel
  Found existing installation: pip 9.0.1
    Uninstalling pip-9.0.1:
      Successfully uninstalled pip-9.0.1
Successfully installed pip-21.1.3 wheel-0.36.2

Option 3: Download and Install Pip on CentOS 7 for Python 2.7

The most recent version of Pip requires Python 3.7 or greater. If you are unable to upgrade your version of Python, here's how you can install Pip on CentOS 7 for older versions:

curl "https://bootstrap.pypa.io/2.7/get-pip.py" -o "get-pip.py"

Once you've downloaded the install script, you can run it with this command:

python get-pip.py

You'll get an output similar to what is seen with the above option.

Step 3: Wrap Up / Verify The Installation

To verify that you have installed Pip correctly, try installing and uninstalling a package.

The following command is to install a new package:

pip install <package_name>

You can uninstall an existing package with the following command:

pip uninstall <package_name>

And here's what that might look like:

pip install h11
Collecting h11
  Downloading h11-0.14.0-py3-none-any.whl (58 kB)
     |████████████████████████████████| 58 kB 2.8 MB/s
Installing collected packages: h11
Successfully installed h11-0.14.0

pip uninstall h11
Found existing installation: h11 0.14.0
Uninstalling h11-0.14.0:
  Would remove:
    /opt/lib/python3.9/site-packages/h11-0.14.0.dist-info/*
    /opt/lib/python3.9/site-packages/h11/*
Proceed (Y/n)? y
  Successfully uninstalled h11-0.14.0

Other Useful Commands

Here are some other commands that might be useful.

Show help and general options:

pip --help

Check what version of Pip is installed:

pip --version

The output will be something like this:

pip 21.2.4 from /opt/lib/python3.9/site-packages/pip (python 3.9)

Or the output may look like this:

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

List all of the Python packages that are installed on your system:

pip list

Your list won't be the same, but the output will look like this:

pip list
Package                            Version
---------------------------------- --------------------
aiohttp                            3.8.4
aiosignal                          1.3.1
alabaster                          0.7.12
[...many more packages...]
yarl                               1.8.2
zict                               2.0.0
zipp                               3.6.0

Show information about the specified Python package:

pip show <package_name>

Here is an example of the output:

pip show pylint
Name: pylint
Version: 2.9.6
Summary: python code static checker
Home-page: https://github.com/PyCQA/pylint
Author: Python Code Quality Authority
Author-email: code-quality@python.org
License: GPL-2.0-or-later
Location: /opt/lib/python3.9/site-packages
Requires: astroid, toml, mccabe, isort
Required-by: spyder

Conclusion

In this guide, you’ve been shown how to install Pip on CentOS 7. Managing and installing Python packages is essential for any Python developer or package distributor. You were shown three options for installing the Pip tool — with the third for older installations — and a verification step to check that the installation was successful.

Need a more secure server option than a VPS? Check out Liquid Web’s line of HIPAA compliant dedicated server hosting options. Our servers outmatch the competition hands down on performance and support. Additionally, check out how Liquid Web’s cloud dedicated servers can skyrocket your site's performance today!

We pride ourselves on being The Most Helpful Humans in Hosting™! Our support staff is always available to assist with any issues related to this article, 24 hours a day, 7 days a week 365 days a year and 366 days on leap years.

Original Publication Date

This article was originally published in December 2014. It has since been updated for accuracy and comprehensiveness.

CentOS 7 Approaching End of Life (EOL) Date

CentOS 7 goes EOL in June 2024. It is expected that there will no longer be security updates available after that date. Active support of CentOS 7 stopped in August 2020.

In most cases, AlmaLinux 8 is the OS being used where CentOS 7 is being replaced. The organization responsible will support the AlmaLinux OS 8 until at least until 2029. Our knowledge base contains a helpful article covering how to install the Pip Package Manager on AlmaLinux.

Avatar for Michael Pruitt

About the Author: Michael Pruitt

Michael Pruitt is a Support Systems Administrator for Nexcess. He brings over a decade of experience to his current role. When not working, Michael can be found officiating roller derby bouts.

Latest Articles

Controlling PHP settings with a custom php.ini file

Read Article

How to install Puppet Server on Linux (AlmaLinux)

Read Article

Email security best practices for using SPF, DKIM, and DMARC

Read Article

Linux dos2unix command syntax — removing hidden Windows characters from files

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article