Table of Contents
- 1 How to Install PIP on Centos 8
- 2 Install pip3 for Python 3
- 3 Installing pip2 for Python 2
- 4 Managing Python Packages with pip
- 4.1 To install a package
- 4.2 Uninstall a package
- 4.3 Search packages
- 4.4 View the full list of packages
- 4.5 List outdated packages:
- 4.6 To upgrade an already installed package
- 4.7 Check pip dependencies
- 4.8 List of packages that need updating
- 4.9 Show packages by package name == version
- 4.10 Useful when outputting to requirements.txt
- 4.11 Package update
- 4.12 Update pip itself
- 4.13 Checking the details of the package
- 5 Conclusion
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 the 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 of 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!
1 thought on “Install PIP on Centos 8”