Read in 2 minutes
How to install Pip on Ubuntu 18.04
Pip is a package management system that simplifies installation and management of software packages written in Python such as those found in the Python Package Index (PyPI). Pip is not installed by default on Ubuntu 18.04, but the installation is pretty straightforward.
In this tutorial, we will show you how to install Python Pip on Ubuntu 18.04 and go through the basics of how to install and manage Python packages with pip.
There are several different ways to install pip on Ubuntu 18.04, depending on your preferences and needs. In this guide, we will install pip for both Python 2
pip and Python 3
pip3 using the
apt package manager.
Before installing any package with
apt it is recommended to update the package list with:
sudo apt update
Install pip for Python 2
The following command will install pip for Python 2 and all of it’s dependencies:
sudo apt install python-pip
Once the installation is complete, we can verify the installation with the following command which will print the pip version:
The version number may vary, but it will look something like this:
pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)
Install pip for Python 3
To install pip3 for Python 3.x run:
sudo apt install python3-pip
Same as before we will verify the pip3 installation with:
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)
Install development tools
We will also install development tools which are required for building Python modules, for Python 2 run:
sudo apt install build-essential python-dev python-setuptools
For Python 3:
sudo apt install build-essential python3-dev python3-setuptools
In this section we will go thought few useful basic pip commands. With pip we can install packages from PyPI, version control, local projects, and from distribution files but in most cases you will install packages from PyPI.
Let’s say we want to install a package named
scrapy, we can do that by issuing the following command:
pip install scrapy
scrapy is Python library for crawling web sites and extracting structured data
To uninstall a package run:
pip uninstall scrapy
To search packages from PyPI:
pip search "search_query"
To list installed packages:
To list outdated packages:
pip list --outdated
Package Version Latest Type ---------- ------- ------ ----- setuptools 39.0.1 39.1.0 wheel
In this tutorial, you have learned how to install pip on your Ubuntu machine and how to manage Python packages using pip. For more information about pip, visit the pip user guide page.
If you have any questions or feedback, feel free to comment below.