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.
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
aptare 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:
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
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
-y flag automatically answers Yes to any prompts during the installation. If you want to review what packages will be installed, omit the
3. Verify the installation by checking the Pip version:
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
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