Pip (Pip installs packages) is a package management tool used to install and manage programs written in Python. PyPa also recommends the use of Pip for installing and managing packages.
In this tutorial, we will discuss how to install Pip on CentOS 7 and how to use Pip to install and manage packages.
We will be downloading the pip install script and use python to install the script. We can download the script using the command below.
# wget "https://bootstrap.pypa.io/get-pip.py" -O "get-pip.py"
Now we can install Pip using the following command:
# python get-pip.py
Once the get-pip script is done installing pip, we can verify the is installed correctly by using the following command:
And the output of that command should look similar to:
pip 7.1.0 from /usr/lib/python2.6/site-packages (python 2.6)
Now that we have the latest version of pip installed, let's take a look at some commands that we can use to manage packages.
Installing packages using pip is easy, following is the command syntax that is used to install packages using pip.
# pip install <package>
It is also possible to specify an exact or minimum package version using the command syntax below.
# pip install package==1.5 # pip install package>=1.5
Upgrading a package using pip is done by use of the argument
--upgrade as we did when upgrading pip to the latest version.
# pip install --upgrade <package>
As much fun can Installing new packages be, we sadly sometimes have to uninstall packages too, we can uninstall packages using the command:
# pip uninstall <package>
Now that we have the basic of pip covered, let's take a look at what other things we can do with pip.
If you ever forget a name of a package or need to look up if a package exists, you can search pip repository by using the following command:
# pip search <search query>
Show is used to finding information such as version, author of a given installed package.
# pip show pytz --- Metadata-Version: 1.1 Name: pytz Version: 2013.7 Summary: World timezone definitions, modern and historical Home-page: http://pythonhosted.org/pytz Author: Stuart Bishop Author-email: firstname.lastname@example.org License: MIT
We can also list all installed python packages including editable by using the following command. Packages are listed in a case-insensitive sorted order.
# pip list
Most python modules are available on pip and pip simplifies the process of installing and managing python modules. Pip is a very useful package management program that every python developer needs to and should know how to use.