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 Ubuntu 15.04 and how to use Pip to install and manage packages.
Python pip package is available on Ubuntu apt-get package repository. But before we can install pip, we have to install necessary packages to run pip.
# sudo apt-get update # sudo apt-get install python-dev build-essential
Now we can install Pip using the following command:
# sudo apt-get install python-pip
However the pip version included on Ubuntu apt-get can be outdated, we can upgrade pip to the latest version by using the command below.
# pip install --upgrade pip
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.