Pip is a command and tool used to manage Python libraries, modules, and packages. Python has a lot of packages because of its popularity and installation, updating and removing them can be done with the Pip package manager.
Python Package Index
First, we have to learn about Python packages and repository. Python Package Index of PyPI is a repository that stores and serves Python packages. PyPI is created by the Python Software Foundation. Currently I provides 196,370 projects with 1,465,722 releases with 371,687 users.
From PyPI, we can search or browse projects and packages. For example, when we search for Django we will see the following results. We will click to the
Django 2.2.5 which is the official Django project.
We will be redirected to the following Django Pip Package page which provides information like installation, project description, release history, download files bug tracker, source code, funding, and documentation.
As Python is a cross-platform scripting/programming language also the package manager Pip is cross-platform too. We can install Pip for operating systems like Windows, Linux, Ubuntu, Fedora, Ubuntu, CentOS, Kali, Mint, MacOSX, RaspberryPi, etc where Python interpreter works. Below you can find how to install Pip for different operating systems and platforms.
How To Install Python Pip For Linux?
Pip Usage and Commands
In this part, we will learn basic usage of Pip and its commands. Pip provides commands to search, install, update, list, etc. packages.
Pip Help and List Commands
We can use the
-h option in order to list simple help information about the pip command like below. Also, general options will be listed.
$ pip -h
For more detailed help
man command can be used. This will list all available commands and options about the pip.
$ man pip
Search Python Package
We can use the
search command and provide the term or package name we want to search. In this example, we will search the package named
$ pip3 search django
Show Python Package Information
We can show the package information with the pip command by using
showcommand and providing the package name we want to show information. In this example, we will show information about the Django package.
$ pip3 show django
Install Python Package
We can install a package by using the
install pip command. We will also provide the package complete name. In this example, we will install the package named Django. During the installation, the main package and its dependencies will be downloaded and extracted required fields.
$ pip3 install django
Update Python Package
Popular python packages are updated regularly. We can update the already installed package with the
install --upgrade command of the pip. We will also provide the package named
django in this example.
$ pip3 install --upgrade django
List Installed Python Packages
We can also list already installed packages. We will use
list pip command like below.
$ pip3 list