How to Install Pip on CentOS

How to Install Pip on CentOS

In this tutorial, we’re going to show you how to install Pip (Python) on CentOS. This tutorial will work for CentOS 7, CentOS 8, and even Fedora.

If you got an error like:

-bash: pip: command not found

When trying to run a pip command, it means that pip isn’t installed on your CentOS.

If you’re running Ubuntu, check this tutorial instead.

Prerequisites for Pip on CentOS

For this tutorial, you’ll need:

  • A CentOS system. It’s usually a Linux VPS. You can get a Linux server from Linode.
  • Root access to your CentOS system. The commands in this tutorial should be/are executed by the root/sudo user.
  • Python 3. If you have Python 2, you need to upgrade ASAP. Python 2 is way over its EOL. You can follow our tutorial on how to install Python 3 on CentOS.

Step 1: Check if Pip is already installed

Pip may already be installed on your CentOS. You can check if it is by running the following command:

pip3 -V

If you get a “command not found” error, it means it’s not installed. In that case, move on to the next steps below.

If you run:

pip -V

And you get a version of the pip that’s installed – it means that an older version of pip is installed and it’s meant for Python 2. Follow the steps below to install Pip3 for Python 3.

Step 2: Update CentOS

The next step is to update your CentOS system with the following command:

yum update -y

Step 3: Install Pip on CentOS

Finally, to install Pip 3 (for Python 3) on CentOS, run the following command:

yum install python3-pip -y

Step 4: Verify if Pip is installed

To verify that Pip was successfully installed, run the following command:

pip3 -V

You should get an output similar to this:

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

If you have another version of Python 3 installed (like 3.10), you can also run

pip3.10 -V

Which should get an output similar to:

pip 21.2.4 from /usr/local/lib/python3.10/site-packages/pip (python 3.10)

How to use Pip on CentOS

The basic syntax of pip commands is:

pip3 <command> [options]

Run the following command to get the help menu for the pip command:

pip3 -h

How to install Pip packages on CentOS

If you want to install a pip package, you need to use this syntax:

pip3 install [package_name]

You can also get more help with the install command by running:

pip3 install -h

The most popular use case is that you’d need to install a list of pip packages from a requirements.txt file.

Once you cd into the directory where that .txt file is located, run the following command:

pip3 install -r requirements.txt

Once you install packages, you can get a list of all the installed pip packages on your system by running:

pip3 list

And you can uninstall a pip package by running:

pip3 uninstall [package_name]

That’s pretty much it! You are now ready to use pip on CentOS.

Leave a comment

Your email address will not be published.

2 thoughts on “How to Install Pip on CentOS”