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 utilization 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 in your system.
Now type the command: # curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
# python get-pip.py
OR
For python3: # python3 get-pip.py
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 # python3 get-pip.py command for python3 & python you can use # python get-pip.py, and you will get the output as shown in the picture below:
Verify the Python version with the command below:
# Pip -V &
# pip3 -V for python3
Install Packages with PIP
You can install packages using the 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.