PIP, an acronym for "Pip Installs Packages," is the package installer for Python. It installs and manages packages/libraries in Python.

Python provides a vast index of modules and packages that are readily available for use in your projects. Downloading and keeping these modules or packages updated frequently can be challenging, mainly when dealing with large projects or needing to maintain such multiple projects.

This is where PIP comes into the picture. It facilitates the installation of packages from the Python Package Index (PyPI) and other supported indexes that provide listings of Python packages.

In this KB, we will cover the installation process of pip on CentOS, Ubuntu, and Debian operating systems.

PIP is already installed on Python 3 (and later versions of Python 2). If Python is already installed on your system, there is a probability that pip is also installed. However, if pip is not installed, you can easily install it by executing the following commands:

Install pip on Ubuntu & Debian:

# apt install python-pip

Or for Python 3 as:

# apt install python3-pip

Here, I am using the Debian operating system; likewise, you can install it on different operating systems with the below commands.

Install pip on AlmaLinux 8 (and later versions):

# sudo dnf install python3 
# sudo dnf install python-pip

Install pip on CentOS 6 and 7:

# sudo yum install epel-release
# sudo yum install python-pip

Install PIP using the Python script:

You can download the PIP installation script with wget or curl. After downloading the script, you can execute it to install the specific Python version and required packages."

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

If you receive “command not found,” install curl on your system by using the command below:

# apt install curl

Now type the command:

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

# python get-pip.py
OR
# python3 get-pip.py (For python3)

If you receive an error as shown in the picture below:

Resolve it with the command 

# apt-get install python3-distutils

Now you can use the below command for Python3 & Python and you will get the output as shown in the picture below:

python3 get-pip.py
python get-pip.py

Verify the Python version with the command below:

# Pip -V
# pip3 -V (for python3)

Install Packages with PIP

You can install packages using PIP with the following command

# pip install package-name

For example, here I am installing numpy, as you can see in the picture below:

Installing pip on Linux is a straightforward process that enables you to manage Python packages efficiently.

By following the steps outlined above, you can easily set up pip and gain access to a vast array of Python libraries, making it easier to develop and run various Python applications on your Linux system.

Conclusion:

Installing PIP on Linux is straightforward and gives you the ability to efficiently manage Python packages. Whether using apt, dnf, yum, or the get-pip.py script, you can quickly set up PIP and access thousands of Python libraries from PyPI. This makes it much easier to develop, deploy, and maintain Python-based projects on your Linux system.

Was this answer helpful? 0 Users Found This Useful (0 Votes)