Pip is the package manager for Python programming language and framework. Python uses packages and modules in order to provide libraries and functions. These packages provided by the Python Package Index or PyPI. PyPI is called a repository index for Python software. PyPI helps us to find and install software developed and shared by the Python community.
Python Package
Python is a very simple programming language where its package or module structure is simple too. Python package contains related modules, py
files, functions, classes we want to use.
Check If Pip Is Installed
We will start by checking whether the pip
is installed. In some cases, pip may be installed by default. By the way, there is two pip version which is related to the Python main versions Python2 and Python3. We will use pip
, pip2
and pip3
commands where pip
is generally related to the pip2
. We will provide the -V
or --version
options like below.
$ pip -V $ pip --version
OR
$ pip3 -V $ pip3 --version
OR
$ pip2 -V $ pip2 --version

We can see that both versions of the pip like pip2 and pip3 are installed in the given example.
Install Pip For Python2 and Python3
If the pip is not installed we can install it to the Linux, Ubuntu, Mint, Kali easily. We can install it for apt
based distributions like Ubuntu, Debian, Mint, Kali, like below.
$ sudo apt install python2-pip

OR for Python3
$ sudo apt install python3-pip

We can install for yum
based distributions like Fedora, CentOS, RedHat like below.
$ sudo yum install python2-pip

OR for Python3
$ sudo yum install python3-pip

More detailed about installing Python can be found in the following link.
How To Install Python Pip For Linux?
Print Help Information
Pip command has very simple usage and provides a dozen commands and options. We can list help information and these command with the pip help
command like below. This will also provide some short description of the command. We will examine most of the and usage in this tutorial.
$ pip help

From the output, we can see that help information about the following commands is provided.
- install
- download
- uninstall
- freeze
- list
- show
- check
- search
- wheel
- hash
- completion
- help
Search Package with Pip
We will start with the search operation where we will provide some search term related to the package we want to find. We will use search
pip command. In this example, we will search the package named scrapy
$ pip3 search scrapy

We can see from the output that there are a lot of packages with the name of the scrapy
List Installed Packages with Pip
Pip is a complete package manager where we can list already installed packages with the list
command. As you gues we will not provide any extra option the list
command.
$ pip3 list

We can see that packages like Django
, pycairo
etc. are all ready installed to the current pip3 package manager.
Install Package with Pip
After searching the package and finding the full and complete package name we can install it with the install
command. But keep in mind that PyPI or pip
provides a lot of packages for the same context and with similar names. So we have to provide the complete and precise name of the package. In this example, we will install the package named gns3-server
.
$ pip3 install gns3

Show Python Package Information with Pip
Each python package has attributes or meta-data like name, version, license etc. We can print this information with the show
command and providing the package name. In this example, we will print gns3-server
package information like below.
$ pip3 show gns3-server

We see that following information about the given Python package is provided.
- `Name` is the official pip name of the package where `gns3-server` is in this example
- `Version` is the package pip version which is recent. In this example `2.1.16` is the recent version of the package gns3-server
- `Summary` is a short description which explains package. gns3-server package description is `GNS3 Server` in this example
- `Home-page` is the package upstream or creator home page which is `http://github.com/GNS3/gns3-server` in this case
- `Author` is the creator of this package python code which is unknown in this example
- `Author-email` is the creator email which is unknown in this example
- `License` is the legal license of the given package which is `GPLv3` in this example
- `Location` is the package path of modules, code and Python code which is `/home/ismail/.local/lib/python3.6/site-packages` in this example. `/home/ismail` is the user who is installed this package
- `Requires` list the dependencies of this packages where `aiohttp`, `aiohttp-cors`, … is required in order to install and run `gns3-server` Python package
Uninstall or Remove Package with Pip
If we do not need the package we can uninstall or remove the package with the uninstall
command like below. We will uninstall the package named gns3-server
.
$ pip3 uninstall gns3-server

We can see that all files under the /home/ismail/.local/lib/python3.6/site-packages/gns3server/
is deleted and verbosely shown as output for the uninstall command.
Only Download Package Do Not Install
If we want to only get some part of the package and do not want to install to the system we can use download
command which will download the package to the current working path. The downloaded file will be compressed and in tar.gz
format with the package name and version. In this example, we will download the package named gns3-server
.

The downloaded file will be named as gns3-server-2.1.16.tar.gz
.