How to Install Pip on Debian 12

Introduction

Pip (Python Installs Packages) is a popular Python package manager application. It retrieves packages from PyPI, a large repository of community-contributed Python packages, and includes the dependencies and libraries needed for each package.

Pip also facilitates Python package management and removal, making it one of the most popular Python package management tools.

In this tutorial, you will learn to install Pip on Debian 12.

How to install Pip on Debian 12 - a tutorial.

Prerequisites

Note: Debian does not create a root account by default if the user does not specify a root password during installation. If you don't have a root account, refer to our guide How to Create a Sudo User on Debian.

Installing Pip on Debian 12

You can install Pip on Debian using one of the two methods:

  • Via the apt package manager. We recommend installing Pip from the official Debian repository. The benefits of installing Pip using apt are easier package management, simplified updates, and installation consistency across systems.
  • Via a Pip installation script. This method lets you install bleeding-edge Pip versions not available in official repositories. However, updating the app later is a more complex process.

In this tutorial, we will install Pip3, designed for Python 3. Debian 12 ships with Python 3, as Python 2 is deprecated. It is important that the Pip version aligns with your Python version to avoid compatibility issues.

Check if Python 3 is installed on your system by running:

python3 --version
Checking the Python program version on Debian.

The output states the Python version installed on your system.

If it doesn't, install Python by running:

sudo apt install python3

After installing Python, move on to the sections below and choose the Pip installation method you prefer.

Method 1: Debian APT Repository

Follow the steps below to install Pip from the official Debian apt repository:

1. Update the package repository to ensure the latest version is installed. Run the command below:

sudo apt update

2. Install the Pip package for Python:

sudo apt install python3-pip -y

The -y flag automatically answers Yes to any prompts during the installation. If you want to review what packages will be installed, omit the -y flag.

3. Verify the installation by checking the Pip version:

pip3 --version
Check Pip version on Debian.

Method 2: Pip Installation Script (get-pip.py)

The second method involves downloading the get-pip.py script using the command line and curl command. The script allows you to install the latest Pip version, which may not be available in Debian's repository. Follow the steps below:

1. Run the following command to download the script:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
Downloading the Pip installation script using curl.

The command downloads the get-pip.py script and saves it in your current working directory.

Note: To check what your current working directory is, use the pwd command.

2. Run the script to initiate the Pip installation. We will run the script through Python:

sudo python3 get-pip.py
Install Pip using the installation script.

The command installs Pip3 on your Debian system.

3. Validate the installation by checking the program version:

pip3 --version

Using Pip on Debian 12

Pip allows you to install, remove, update, and manage Python packages. This section shows some basic operations for using Pip on Debian 12.

Install Python Packages

The syntax for installing Python packages is:

pip install [package_name]

For example, to install Numpy, run the command below:

pip install numpy
Installing a package using Pip on Debian.

The command installs the package and all its dependencies.

List Installed Packages

List all the installed Python packages by running the command below:

pip list
Listing installed Python packages.

The command outputs a list of the installed Python packages.

Download Python Packages

Pip allows users to download Python packages, which can later be installed on another machine or without an Internet connection.

The syntax for downloading a Python package is:

pip download [package_name]

For example, to download the tensorflow package, an open-source library for machine learning, run:

pip download tensorflow
Downloading a Python package for later installation.

The command downloads the package and all its dependencies, allowing you to install it later.

Show Python Package

To obtain information about a specific Python package, utilize the show option. The syntax is:

pip show [package_name]

For example, to display information about the numpy package, run:

pip show numpy
Showing Python package information.

The output shows the package version, description, author information, and other details about the package contained in the repository.

Uninstall Python Package

To uninstall a Python package from your system, use the syntax below:

pip uninstall [package_name]

For example, to uninstall numpy, run:

pip uninstall numpy
Uninstalling a Python package with Pip.

When prompted, press y to confirm the uninstall and Enter to proceed. The command removes the package and its dependencies from your system.

Conclusion

This tutorial showed how to install and use the Pip package manager on Debian 12 with practical examples.

Next, see how to install Pip on Debian 9, 10, and 11 if you use an older version of Debian.

Was this article helpful?
YesNo
Bosko Marijan
Having worked as an educator and content writer, combined with his lifelong passion for all things high-tech, Bosko strives to simplify intricate concepts and make them user-friendly. That has led him to technical writing at PhoenixNAP, where he continues his mission of spreading knowledge.
Next you should read
How to Install Pip on Mac
December 14, 2023

Pip is a Python package manager allowing users to connect to an online repository of public packages. This tutorial shows how to install Pip on macOS.
Read more
How to Install Pip on CentOS 8
August 3, 2020

Pip is a package manager for Python allowing you to install Python packages. This tutorial shows how to install Pip on CentOS 8.
Read more
How to Install Pip on Ubuntu
August 20, 2024

Pip is a software utility that downloads packages from PyPI – the Python Package Index. This guide will walk you through installing PIP on Ubuntu.
Read more
How to Install PIP on Windows
November 30, 2023

PIP for Python is a utility to manage PyPI package installations from the command line. This tutorial will show how to install PIP, check its version, upgrade and configure PIP.
Read more