Installing Python3 pip 3 on Linux|Ubuntu with Sudo Apt-Get

Posted April 4, 2024
Installing Python3 pip 3 on Linux|Ubuntu with Sudo Apt Get

Linux distros come ready with Python3. They need Python to run some Linux packages. At the same time, you need to run Python3 on your Linux machine to create Python apps.

Python3 requires Pip3. You use Pip3 to install any Python3 related packages within your Linux Python setup. In this case, Linux uses the APT command, sudo apt-get install python3-pip. This Sudo Apt Get command will install and get Pip3 ready on Linux.

In this guide, you will explore the sudo apt-get install python3-pip command with Linux. You will learn different ways to install Python3 Pip3 on your Linux distros as such:

  • How to install pip3 on Linux using Pip Python Script
  • Using sudo apt-get install python3-pip command to get Pip ready.
  • How to remove and Uninstall pip3 from Linux.
  • Upgrading the Pip3 version on your Linux machine.

Ready? Buckle up and Install Python3 pip 3 on Linux|Ubuntu with Sudo Apt Get like a Pro.

Requisites to Install pip3 on Linux with Sudo Apt Get

To get started, you need:

  • A Linux terminal with sudo privileges to run sudo apt-get commands.
  • If you don’t have Python3, installed on Linux, check the following guide to get one ready.

Related: How to Install|Upgrade Python 3.10 on Ubuntu 22.04|20.04

  • Ensure Linux has its package index up to date.

Installing Python3 pip3 with Sudo Apt Get and Linux

In this first section, you get pip3 ready using the Sudo Apt Get command. First, ensure Python is ready:

python3 --version

I’m using Python3.10 as such. If you want to update to a later version, check this How to Update and Upgrade Python3 Version guide.

Install pip3 on Linux with Sudo Apt Get

Python3 seems ready, let’s now get pip3 to this Linux machine. Go ahead and run the following sudo apt-get install python3-pip command:

sudo apt-get install python3-pip -y

Install pip3 on Linux with Sudo Apt Get

Now, Linux will download pip3 which is compatible with your available Python3 version.

Confirm and make sure Sudo apt-get installed the right pip3:

sudo pip3 --version

Install pip3 on Linux with Sudo Apt Get

And there you have installed Python3 pip 3 on Linux with Sudo Apt-Get.

Updating Python3 pip3 on Linux

If you want Linux to run the latest pip3 libraries, you don’t need to use the sudo apt-get install python3-pip command.

You will use --upgrade to target the installed pip3 and let Linux handle the rest.

Use the following command to update pip3:

sudo pip3 install --upgrade pip

Install pip3 on Linux with Sudo Apt Get

Linux will update pip3 to the latest version. In this case, Linux will use pip3 version 24.0. Confirm this using the following command:

sudo pip3 --version

Install pip3 on Linux with Sudo Apt Get

Installing Pip3 Using Python Script and Linux

If you don’t want to use sudo apt-get install python3-pip command to get python3-pip ready, you will need to get Pip3 from Bootstrap Pypa.

This repository saves pip that you can download and install on your Linux.

Install pip3 on Linux with Sudo Apt Get

This repository has a pip that contains get-pip.py. You will download this file to Linux and install Pip3 as follows:

Install pip3 on Linux with Sudo Apt Get

Next, check and confirm you have the get-pip.py in your path with ls:

Install pip3 on Linux with Sudo Apt Get

If you have this file, run the following command to install Pip3:

sudo python3 get-pip.py

Install pip3 on Linux with Sudo Apt Get

How to Run Python3 Pip3 Commands with Linux

Now that you have Pip3 ready, you can use it to manage your Python3 packages. For example, to install a package, you run the command in the following format, where pandas is the package name:

pip install pandas

Install pip3 on Linux with Sudo Apt Get

Confirm the installed Pip3 packages using:

pip list

#Output
Package Version
------------------- ----------------
attrs 21.2.0
Automat 20.2.0
bcrypt 3.2.0
certifi 2020.6.20
numpy 1.26.4
pandas 2.2.1

You can also use the pip show command with the Package name you need to check:

pip show pandas

To remove this package use the pip uninstall command as such:

pip uninstall pandas

Install pip3 on Linux with Sudo Apt Get

Pip3 will also Download Python Packages such as TensorFlow, matplotlib, etc. Your command syntax will be as follows:

pip download tensorflow

Uninstalling Pip3 from Linux

Once you’re done with Pip3, use the following command to remove it from Linux:

sudo apt autoremove -purge python3-pip
sudo apt-get purge python3-pip

Install pip3 on Linux with Sudo Apt Get

To completely remove Pip3, you need to remove the pip files saved on /usr/**local/bin/**pip3. Check this path as follows:

ls /usr/**local/bin/**pip3

Install pip3 on Linux with Sudo Apt Get

This means you need to remove the /usr/local/bin/pip3 file with the following command:

sudo rm -r /usr/local/bin/pip3

Now check Pip3 and it should be unavailable on Linux:

sudo pip3 --version

Install pip3 on Linux with Sudo Apt Get

Conclusion

You have successfully installed Python3 Pip3 on Linux and learned:

  • How to install pip3 on Linux using Pip Python Script
  • Using sudo apt-get install python3-pip to get Pip ready.
  • How to remove and Uninstall pip3 from Linux.
  • Upgrading Pip3 version on your Linux machine
Installing Python3 pip 3 on Linux|Ubuntu with Sudo Apt-Get

Written By:

Joseph Chege