How to install Python pip 21 on Ubuntu 21.10

Pip is a package management system written in Python and is used to install and manage software packages. It connects to an online repository of public packages called the Python Package Index. It can also be configured to connect to other package repositories.

Usually, Pip is automatically installed while working in a virtual environment, and also if you are using Python that has not been modified by the redistributor to remove ensure pip.

Pip is recommended tool for installing Python packages. For you to start using pip, you need to have python installed on your system.

Ways of installing pip

  • Using virtual environment method
  • Using script

Using Virtual environment method

This invocation will install pip if it is not already installed. In order to ensure that the latest pip installed is the current one pass the –upgrade parameter to the above command.

$ python -m pip install --upgrade pip

This method requires you have a virtual environment set up first.

Let me show you how to set up a virtual environment.

First, let’s create a directory called nextgentips

$ sudo mkdir nextgentips
$ cd nextgentips

We will create a virtual environment called nextvenv

$ python3 -m venv nextvenv

In case you encounter the following error, follow the instruction in order to make necessary changes.

The virtual environment was not created successfully because ensurepip is not
available.  On Debian/Ubuntu systems, you need to install the python3-venv

Run the following command to correct the following error.

$ sudo apt install python3.9-venv
The following additional packages will be installed:
The following NEW packages will be installed:
  python-pip-whl python3.9-venv
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 1902 kB of archives.
After this operation, 2320 kB of additional disk space will be used.
Do you want to continue? [Y/n] y

Press Y to allow the installation to continue.

Go ahead and run this command again python3 -m venv nextvenv, this time it will run successfully.

$ python3 -m venv nextvenv

To start using the virtual environment, run the following command to activate the virtual environment.

$ source nextvenv/bin/activate

When you see something like this (nextvenv) [email protected]:~/nextgentips#, you know that you have activated the virtual environment successfully.

Run the following command to install the latest pip.

$ python -m pip install --upgrade pip

Sample output will look like this:

Requirement already satisfied: pip in ./nextvenv/lib/python3.9/site-packages (20.3.4)
Collecting pip
  Downloading pip-21.3.1-py3-none-any.whl (1.7 MB)
     |████████████████████████████████| 1.7 MB 25.0 MB/s 
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.3.4
    Uninstalling pip-20.3.4:
      Successfully uninstalled pip-20.3.4
Successfully installed pip-21.3.1

Installing pip using bash script

First, you will need to add the universe repo. Use the following command to do so.

$ sudo add-apt-repository universe
Adding component(s) 'universe' to all repositories.
Press [ENTER] to continue or Ctrl-c to cancel.
Hit:1 impish InRelease
Hit:2 main InRelease                    
Hit:3 impish-updates InRelease                            
Hit:4 impish-security InRelease
Hit:5 impish-backports InRelease
Reading package lists... Done

Now let’s get installation script from using curl

$ curl --output

When the download is complete, move ahead to install the script with the following command;

$ sudo python3

You will get the following sample output.

Collecting pip<21.0
  Downloading pip-20.3.4-py2.py3-none-any.whl (1.5 MB)
     |████████████████████████████████| 1.5 MB 33.1 MB/s 
Collecting wheel
  Downloading wheel-0.37.0-py2.py3-none-any.whl (35 kB)
Installing collected packages: wheel, pip
Successfully installed pip-20.3.4 wheel-0.37.0
WARNING: You are using pip version 20.3.4; however, version 21.3.1 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command.

You can upgrade to the latest version using

$ python3 -m pip install --upgrade pip


I am glad you have learned how to install pip on Ubuntu 21.10. Continue visiting our page for more good content.

About Kipkoech Sang

I am a technology enthusiast who loves to share gained knowledge through offering daily tips as a way of empowering others. I am fan of Linux and all other things open source.
View all posts by Kipkoech Sang →

Leave a Reply

Your email address will not be published. Required fields are marked *