
Pip is a standard package management tool used for installation of packages in Python. Using pip, you can search, download and install packages from Python Package Index (PyPI) and other repositories. This tutorial explains how to install Pip on CentOS 8.
Installing pip on CentOS 8
There are two Python versions currently, Python 2 and Python 3. CentOS 8 repository allows access to both pip versions for Python 2 as well as Python 3 interpreter. On CentOS 8, you can install packages either with dnf
or yum
command. We can install pip2
or pip3
package depending on what python version we use, or we could also install both packages as well, without any problem.
Installing pip for Python 3 (pip3)
Open your terminal on your CentOS and run the below command as root or sudo user to install pip for Python 3:
sudo dnf install python3
The above command will install Python 3.6 and pip. To verify that pip is installed perfectly, type:
pip3 --version
This will print the pip version. It may vary depending when you are installing.
pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6)
Next, you should install the development tools to install and build python modules with pip. Run the below commands:
sudo yum install python3-devel
sudo yum groupinstall 'development tools'
Installing pip for Python 2 (pip2)
Run the following command to install Python 2 and pip:
sudo dnf install python2
Verify the installation by typing:
pip2 --version
It show show something like below:
Python 2.7.15
Same as Python 3 you need to install development tools:
sudo yum install python2-devel
sudo yum groupinstall 'development tools'
Manage Python Packages with pip
Here, we will see examples how to use pip commands.
Below is the syntax to install package with PIP:
pip install PACKAGE_NAME
For example, to install names
python package, run below command:
pip install names
names
is a package which will return random names.
You can uninstall a package use pip uninstall
followed by the package name:
pip uninstall PACKAGE_NAME
To search package using PIP just type as below:
pip search PACKAGE_NAME
Get the list of installed packages using below command:
pip list
The list of outdated packages can be retrieved by:
pip list --outdated
You can upgrade already installed packages to latest version using below command:
pip install --upgrade PACKAGE_NAME
Conclusion
This tutorial shown you how to install Pip on CentOS 8. Also, described how to manage Python packages using pip. You can get more details about pip from this guide.
To ask any question, feel free to leave a comment.
Leave a Reply