How to install pip on Ubuntu 24.04

How to install pip on Ubuntu 24.04

Welcome to this tutorial on installing pip on Ubuntu 24.04. Pip is a package manager for Python that helps you install and manage additional libraries and dependencies that are not included in the standard library. It’s secure and widely used by many developers to manage Python packages and projects. This guide will show you how to install pip on Ubuntu 24.04 in a few steps.

Prerequisites

  • An Ubuntu 24.04 VPS
  • At least 2GB of RAM
  • SSH root access or a system user with sudo privileges

Step 1. Update System Packages

To start, log in to your Ubuntu 24.04 using SSH:

ssh root@IP_Address -p Port_number

Replace ‘IP_Address’ and ‘Port_number’ with your server’s IP address and SSH port number. If needed, replace ‘root’ with the username of your sudo account.

Once logged in, you must ensure that all UbuntuOS packages installed on the server are up to date. You can do this by running the following commands:

apt update -y && apt upgrade -y

Method 1: Install pip on Ubuntu 24.04 using the package manager

Since Python3 is often pre-installed on Ubuntu 24.04, you should first check if it is already installed on your system by using the following command:

# python3 -V
Python 3.12.3

The output above indicates that Python3 is pre-installed. You can now proceed with installing pip using package manager.

sudo apt install python3-pip

After the installation finishes, verify the pip version by using the following command:

# pip --version
pip 24.0 from /usr/local/lib/python3.12/dist-packages/pip (python 3.12)

Method 2: Install pip on Ubuntu 24.04 From the Source

If you want to install a specific version of pip on Ubuntu, you can compile it from the source.

Let’s download the source code for an old pip version. You can replace 22.1.2 with the version you want to install:

curl -L https://files.pythonhosted.org/packages/4b/b6/0fa7aa968a9fa4ef63a51b3ff0644e59f49dcd7235b3fd6cceb23f202e08/pip-22.1.2.tar.gz -o pip-22.1.2.tar.gz

Output:

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer
NVME 2 VPS

Now just $43 .99
/mo

GET YOUR VPS
# curl -L https://files.pythonhosted.org/packages/4b/b6/0fa7aa968a9fa4ef63a51b3ff0644e59f49dcd7235b3fd6cceb23f202e08/pip-22.1.2.tar.gz -o pip-22.1.2.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 2063k  100 2063k    0     0  6824k      0 --:--:-- --:--:-- --:--:-- 6853k

Next, extract the downloaded file using the following command:

tar -zxf pip-22.1.2.tar.gz

After extracting, navigate to the pip installation folder and run the following commands:

# cd pip-22.1.2/
# python3 setup.py install

Here’s how the output should look:

Adding pip 22.1.2 to easy-install.pth file
Installing pip script to /usr/local/bin
Installing pip3 script to /usr/local/bin
Installing pip3.12 script to /usr/local/bin

Installed /usr/local/lib/python3.12/dist-packages/pip-22.1.2-py3.12.egg
Processing dependencies for pip==22.1.2
Finished processing dependencies for pip==22.1.2

After the installation finishes, verify the pip version by using the following command:

# pip3 --version
pip 22.1.2 from /usr/local/lib/python3.12/dist-packages/pip-22.1.2-py3.12.egg/pip (python 3.12)

Refer to their official documentation for additional details about pip, its features, and configuration.

Of course, you don’t have to install pip on Ubuntu 24.04 if you use one of our Fully-Managed Python Hosting services, in which case you can ask our expert Linux admins to install and configure pip on your Ubuntu VPS for you. They are available 24×7 and will take care of your request immediately.

If you liked this post on how to install pip on Ubuntu 24.04, please share it with your friends or leave a comment in the section below.

Leave a Comment