How to Install pip on CentOS 7

When using python on CentOS 7, we need a package manager that can install various other python packages and third party libraries. The pip is the default package manager for Python, which you can use to install third party python libraries on CentOS 7.

There are several ways to install a Python package on CentOS 7. The easiest and the most effective is the one using pip command. To be able to use it to install python packages, pip needs to be installed first.

Before we install pip

You need to install specific version of the pip command depends on python version you are using. Foy python 2, you need to install python2-pip package, for python 3 it is the python34-pip.

Learn how to install Python 3 on CentOS 7

Also, The pip command is not available from the default CentOS 7 software repository. So first we need to enable epel repository.

yum install epel-release

Now the epel repository is enabled, we can install pip command with the yum package manager.

If you are using python 2, run:

yum -y  python2-pip

For python 3, run:

yum -y install python34-pip

To install package for python version 2 you will use either pip or pip2 command, for python 3 you need to use pip3 command.

Installing Python packages with pip

To install a package for python 2, type:

pip install package-name

For python 3, Type:

pip3 install package-name

For example, to install flask framework on CentOS 7, run:

pip install flask

Addition to installing packages, pip offers the ability to uninstall packages, search packages, list packages and etc.

To uninstall a python package on CentOS 7, Type:

pip uninstall package-name

For example, to uninstall flask, run:

pip uninstall flask

To search for new third party libraries, run:

pip search keyword

For command help, Type:

pip --help