How to Install Pip on CentOS 7
3 min read
Pip is a package management system that simplifies installation and management of software packages written in Python such as those found in the Python Package Index (PyPI). Pip is not installed by default on CentOS 7, but the installation is pretty simple.
In this tutorial, we will walk through the steps required to install Python
pip on CentOS 7 using the
yum package manager and cover the basics of how to install and manage Python packages with pip.
When installing python modules globally you should prefer to install distribution provided python modules using
yum because they are tested to work properly on CentOS 7. Use pip to install python modules globally only if there is no rpm package for the python module.
In most cases, you should use pip inside a virtual environment only. Python
Virtual Environments allows you to install Python modules in an isolated location for a specific project, rather than being installed globally. This way you do not have to worry about affecting other Python projects.
Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges .
Installing pip on CentOS
To install pip on your CentOS machine, follow these steps:
1. Add the EPEL Repository
Pip is not available in CentOS 7 core repositories. To install pip we need to enable the EPEL repository :
sudo yum install epel-release
2. Install pip
Once the EPEL repository is enabled we can install pip and all of its dependencies with the following command:
sudo yum install python-pip
3. Verify Pip installation
To verify that the pip is installed correctly run the following command which will print the pip version:
The version number may vary, but it will look something like this:
pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7)
Install development tools
Development tools are required for building Python modules, you can install them with:
sudo yum install python-devel
sudo yum groupinstall 'development tools'
Managing Python Packages With PIP
In this section, we will go through a few useful basic pip commands. With pip, we can install packages from PyPI, version control, local projects and from distribution files. Usually, you will install packages from PyPI.
Let’s say we want to install a package named
twisted, we can do that by issuing the following command:
pip install twisted
To uninstall a package run:
pip uninstall twisted
To search packages from PyPI:
pip search "twisted"
To list installed packages:
To list outdated packages:
pip list --outdated
You have successfully installed pip on your CentOS 7 system and you learned how to easily install and uninstall Python modules with pip. You can also check our guide about how How to install Python 3 with Pip 3 on CentOS 7 .
For more information about pip, check the pip user guide . If you have any questions or feedback, feel free to comment below.