Pip is a command-line tool that allows you to install software packages written in Python. Learn how to install Pip on Ubuntu and how to use it for installing Python applications.
There are numerous ways to install software on Ubuntu. You can install applications from the software center, from downloaded deb files, from PPAs, from Snap packages, using Flatpak, using AppImage and even from the good old source code.
Here’s another way to install packages on Ubuntu. It’s called pip and you can use it to install Python-based applications.
What is pip?
You can use pip to install packages listed in the Python Package Index (PyPI).
As a software developer, you can use pip to install various Python modules and packages for your own Python projects.
As an end user, you may need pip for installing some applications that are developed using Python and can be installed easily using pip. One such example is the
Let’s see how you can install pip on Ubuntu and other Ubuntu-based distributions.
How to install pip on Ubuntu
Pip is not installed on Ubuntu by default. You’ll have to install it. Installing pip on Ubuntu is really easy. I’ll show you how to do it in a moment.
Ubuntu 18.04 has both Python 2 and Python 3 installed by default. Hence, you should install pip for both
Pip, by default, refers to the Python 2 version. Pip for Python 3 is referred to as pip3.
Note: I’m using Ubuntu 18.04 in this tutorial, but the instructions here should be valid for other versions like Ubuntu 16.04, 18.10, etc. You may also use the same commands on other Linux distributions based on Ubuntu such as Linux Mint, Linux Lite, Xubuntu, Kubuntu, etc.
Install pip for Python 2
First, make sure that you have Python 2 installed. On Ubuntu, use the command below to verify.
If there’s no error and a valid output that shows the Python version, you have Python 2 installed. So now you can install pip for Python 2 using this command:
sudo apt install python-pip
It will install pip and a number of other dependencies with it. Once installed, verify that you have pip installed correctly.
It should show you a version number, something like this:
pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)
This mans that you’ve successfully installed pip on Ubuntu.
Install pip for Python 3
First, make sure that Python 3 is installed on Ubuntu. To check that, use this command:
If it shows you a number like Python 3.6.6, Python 3 is installed on your Linux system.
Now you can install pip3 using the command below:
sudo apt install python3-pip
You should verify that pip3 has been installed correctly using this command:
It should show you a number like this:
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)
This means that pip3 is successfully installed on your system.
Top command is good but there are better alternatives to Top. Take a look at these system monitoring tools that are similar to top but are actually better.
How to use pip commands
Now that you’ve installed pip, let’s quickly see some of the basic pip commands. These commands will help you use pip commands for searching, installing and removing Python packages.
To search for packages in the
pip search search_string
For example, if you search on ‘stress’, it will show all the packages that have the string ‘stress’ in their name or description.
pip search stress stress (1.0.0) - A trivial utility for consuming system resources. s-tui (0.8.2) - Stress Terminal UI stress test and monitoring tool stressypy (0.0.12) - A simple program for calling stress and/or stress-ng from python fuzzing (0.3.2) - Tools for stress testing applications. stressant (0.4.1) - Simple stress-test tool stressberry (0.1.7) - Stress tests for the Raspberry Pi mobbage (0.2) - A HTTP stress test and benchmark tool stresser (0.2.1) - A large-scale stress testing framework. cyanide (1.3.0) - Celery stress testing and integration test support. pysle (1.5.7) - An interface to ISLEX, a pronunciation dictionary with stress markings. ggf (0.3.2) - global geometric factors and corresponding stresses of the optical stretcher pathod (0.17) - A pathological HTTP/S daemon for testing and stressing clients. MatPy (1.0) - A toolbox for intelligent material design, and automatic yield stress determination netblow (0.1.2) - Vendor agnostic network testing framework to stress network failures russtress (0.1.3) - Package that helps you to put lexical stress in russian text switchy (0.1.0a1) - A fast FreeSWITCH control library purpose-built on traffic theory and stress testing. nx4_selenium_test (0.1) - Provides a Python class and apps which monitor and/or stress-test the NoMachine NX4 web interface physical_dualism (1.0.0) - Python library that approximates the natural frequency from stress via physical dualism, and vice versa. fsm_effective_stress (1.0.0) - Python library that uses the rheological-dynamical analogy (RDA) to compute damage and effective buckling stress in prismatic shell structures. processpathway (0.3.11) - A nifty little toolkit to create stress-free, frustrationless image processing pathways from your webcam for computer vision experiments. Or observing your cat.
If you want to install an application using pip, you can do so in the following manner:
pip install package_name
Pip doesn’t support tab completion so the package name needs to be exact. It will download all the necessary files and install that package.
If you want to remove a Python package installed via pip, you can use the remove option.
pip uninstall installed_package_name
You can use pip3 instead of pip in the above commands.
I hope this quick tip helped you install pip on Ubuntu. If you have any questions or suggestions, please let me know in the comments section below.