Pip is a package manager for the Python programming language. Pip makes it easier to install plugins and other software packages for Python.
There are two versions – the most recent version is for Python 3, and there is a legacy version for the older Python 2.
This guide will show you how to install Pip for Python 2 and Python 3 on CentOS 8.
- A system with CentOS 8 installed
- A user account with sudo or root privileges
- Access to a command line or terminal window (Activities > Search > Terminal)
Installing Pip for Python 3
Python 3 is the most recent, stable, long-term supported version of Python. If you don’t specifically need Python 2 for compatibility with older applications, it’s recommended to use Python 3.
Step 1: Update System Repositories
To update system repositories, open a terminal window and enter the following command:
sudo yum update
This will refresh the local list of available software packages. If
yum update hasn’t been run recently, it may take a few minutes to install updates.
Note: For some updates, such as security keys, you may be prompted to confirm the installation with
y > Enter.
Step 2: Install Python 3
Some newer versions of CentOS 8 include Python 3 by default. If the system already has Python 3 installed, skip this step.
To install Python 3, open a terminal window and enter the command:
sudo yum –y install python3
Step 3: Install Pip for Python 3
To install Pip for Python 3 open the terminal window, enter the following:
sudo yum –y install python3-pip
Note: Your system may already have Python3-pip installed. If so, the output will report that there is nothing to do.
Step 4: Confirm Pip is Installed
One way to test whether an application is installed is by checking its version number. To check the version of Pip 3, enter:
The output displays the pip3 version installed on your system.
Note: Make sure to use a capital
–V. A lower-case
–v will display an error and list of commands.
Installing Pip for Python 2
CentOS 8 allows you to install multiple versions of Python at the same time. You can install Python 2 in parallel to an existing Python 3 installation.
Step 1: Update Repositories
If you updated the repositories in the previous section, skip to the next step.
Update repositories with the command:
sudo yum update
Note: Some packages, such as security updates, will prompt you to confirm the installation by typing
y and hitting Enter.
Step 2: Install Pip 2
To install Pip2, open the terminal window, enter the command:
sudo yum –y install python2-pip
Note: If Python 2 isn’t installed, this step will install it. Python 2 is a dependency for the pip2 package.
Step 3: Verify the Installation
Check the version of pip2 to verify that it is installed on your Centos 8 system:
The system should display the version of pip2.
Note: If you’re concerned that Python 2 may not have been installed, verify the installation by entering
sudo yum –y install python2. The system should report nothing to do.
You have installed Pip for Python 2 and Python 3 on your CentOS 8 system. Use Pip to manage the most popular Python packages easily.
Get started with a basic script like getting the current time and date in Python.