Install PIP on Centos 8

Introduction

In this tutorial. How to install pip on Centos 8. Pip is a package management system that allows you to install, remove, and otherwise manage software packages written in Python.

How to Install PIP on Centos 8

Two Python versions are Python 2 and Python 3.

Install pip3 for Python 3

sudo dnf install python3

The output is as below:

[devopsroles@server1 ~]$ sudo dnf install python3
[sudo] password for devopsroles: 
Last metadata expiration check: 0:07:32 ago on Wed 02 Sep 2020 09:15:00 PM +07.
Dependencies resolved.
==========================================================================================================
 Package                  Architecture Version                                      Repository       Size
==========================================================================================================
Installing:
 python36                 x86_64       3.6.8-2.module_el8.1.0+245+c39af44f          AppStream        19 k
Installing dependencies:
 python3-pip              noarch       9.0.3-16.el8                                 AppStream        19 k
 python3-setuptools       noarch       39.2.0-5.el8                                 BaseOS          162 k
Enabling module streams:
 python36                              3.6                                                               

Transaction Summary
==========================================================================================================
Install  3 Packages

Total download size: 201 k
Installed size: 466 k
Is this ok [y/N]: y
Downloading Packages:
(1/3): python36-3.6.8-2.module_el8.1.0+245+c39af44f.x86_64.rpm            7.3 kB/s |  19 kB     00:02    
(2/3): python3-pip-9.0.3-16.el8.noarch.rpm                                7.1 kB/s |  19 kB     00:02    
(3/3): python3-setuptools-39.2.0-5.el8.noarch.rpm                          52 kB/s | 162 kB     00:03    
----------------------------------------------------------------------------------------------------------
Total                                                                      43 kB/s | 201 kB     00:04     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                  1/1 
  Installing       : python3-setuptools-39.2.0-5.el8.noarch                                           1/3 
  Installing       : python36-3.6.8-2.module_el8.1.0+245+c39af44f.x86_64                              2/3 
  Running scriptlet: python36-3.6.8-2.module_el8.1.0+245+c39af44f.x86_64                              2/3 
  Installing       : python3-pip-9.0.3-16.el8.noarch                                                  3/3 
  Running scriptlet: python3-pip-9.0.3-16.el8.noarch                                                  3/3 
  Verifying        : python3-pip-9.0.3-16.el8.noarch                                                  1/3 
  Verifying        : python36-3.6.8-2.module_el8.1.0+245+c39af44f.x86_64                              2/3 
  Verifying        : python3-setuptools-39.2.0-5.el8.noarch                                           3/3 

Installed:
  python3-pip-9.0.3-16.el8.noarch                            python3-setuptools-39.2.0-5.el8.noarch       
  python36-3.6.8-2.module_el8.1.0+245+c39af44f.x86_64       

Complete!

Check version pip

pip3 --version

The output as below

[devopsroles@server1 ~]$ pip3 --version
pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6)

To install and build Python modules with pip, you need to install the Development tools:

sudo yum install python3-devel
sudo yum groupinstall 'development tools'

Installing pip2 for Python 2

sudo dnf install python2
pip2 --version
sudo yum install python2-devel
sudo yum groupinstall 'development tools'

For example, I have installed two python3 and python2 on Centos 8 as below

[devopsroles@server1 ~]$ sudo yum list installed | grep pip
libpipeline.x86_64                          1.5.0-2.el8                           @anaconda 
platform-python-pip.noarch                  9.0.3-16.el8                          @anaconda 
python2-pip.noarch                          9.0.3-16.module_el8.2.0+381+9a5b3c3b  @AppStream
python2-pip-wheel.noarch                    9.0.3-16.module_el8.2.0+381+9a5b3c3b  @AppStream
python3-pip.noarch                          9.0.3-16.el8                          @AppStream
python3-pip-wheel.noarch                    9.0.3-16.el8                          @anaconda 

Managing Python Packages with pip

Typically, you should use pip inside a virtual environment only. It is used when separating the Python execution environment, such as when you want to change the Python execution environment for each project or you do not want to keep the local environment dirty venv.

In this section, we will go through several basic pip commands.

To install a package

pip install flask

If you want to install a specific version of the package

pip install flask==1.0.0

Uninstall a package

pip uninstall package_name

Search packages

pip search "package_name"

View full list of packages

pip list

List outdated packages:

pip list --outdated

To upgrade an already installed package

pip3 install --upgrade package_name

Check pip dependencies

pip check

List of packages that need updating

pip list -o

Show packages by package name == version

pip freeze

Useful when outputting to requirements.txt

pip freeze > requirements.txt

Package update

pip install  -U package_name

Update pip itself

pip install  -U pip

Checking the details the package

pip show package-name

Conclusion

How to install pip on CentOS 8 and how to easily install and uninstall Python modules with pip. Thank you for reading the DevopsRoles page!

About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created DevopsRoles.com site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

1 thought on “Install PIP on Centos 8

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.