How to Install Pip on Ubuntu 20

How to Install Pip on Ubuntu 20

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.

To install PIP on Ubuntu 20.04, you should make sure to enable universe repository and then install python3-pip package like this:

sudo add-apt-repository universe
sudo apt install python3-pip

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?

Pip stands for “Pip Installs Packages”. Pip is a command-line based package management system. It’s used to install and manage software written in the Python language.

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 Stress Terminal application, which you can easily install with pip.

Let’s see how you can install pip on Ubuntu and other Ubuntu-based distributions.

How to install pip on Ubuntu, Linux Mint and other Ubuntu-based distributions

Install pip on Ubuntu LinuxInstall pip on Ubuntu Linux

Ubuntu 18.04 has both Python 2 and Python 3 installed by default and hence it has two possible variants of PIP for each Python versions. Pip, by default, refers to the Python 2 version. Pip for Python 3 is referred to as pip3. 

Python 2 is deprecated and not available in Ubuntu 20.04 and higher versions. You can only install PIP3.

First, make sure that Python 3 is installed on Ubuntu. To check that, use this command:

python3 –version

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:

pip3 –version

It should show you a number like this:

pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)

This means that pip3 is successfully installed on your system.

Install pip for deprecated Python 2 version (for Ubuntu 18.04 only)

If you really need pip2 for some reason, here’s what you need to do.

First, make sure that you have Python 2 installed. On Ubuntu, use the command below to verify.

python2 –version

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.

pip –version

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.

.ugb-container__side{padding-top:35px !important;padding-bottom:35px !important}.ugb-dd8ad3f-wrapper.ugb-container__wrapper:before{background-color:#f1f1f1 !important}.ugb-dd8ad3f-content-wrapper > h1,.ugb-dd8ad3f-content-wrapper > h2,.ugb-dd8ad3f-content-wrapper > h3,.ugb-dd8ad3f-content-wrapper > h4,.ugb-dd8ad3f-content-wrapper > h5,.ugb-dd8ad3f-content-wrapper > h6{color:#222222}.ugb-dd8ad3f-content-wrapper > p,.ugb-dd8ad3f-content-wrapper > ol li,.ugb-dd8ad3f-content-wrapper > ul li{color:#222222}]]>

Recommended Read:

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.

Install a package with pip

There are two ways to install a package with PIP. You either install it for the currently logged in user or you install system wide.

If you use –user option, it installs the package for the logged in user i.e. you without needing sudo access. The installed python software is available only for you and other users on your system (if any) cannot use it.

pip3 install –user python_package_name

If you remove the –user option, the package will be installed system wide and it will be available for all the users on your system. You’ll need sudo access in this case.

sudo pip3 install python_package_name

PIP doesn’t support tab completion by default. So you need to know the exact package name that you want to install. How do you get that? I show that to you in the next section.

Search for packages using pip

To search for packages in the Python Package Index, you can use the following pip command:

pip3 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.

pip3 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.

Remove packages installed via pip

If you want to remove a Python package installed via pip, you can use the remove option.

pip3 uninstall installed_package_name

You can use pip instead of pip3 in the above commands if you are using pip2 in Ubuntu 18.04. 

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.

Like what you read? Please share it with others.

Source

Share