Debian

How to Install pip on Debian 12

Pip Installs Python commonly referred to as pip is a Python package installer that allows you to install and manage Python packages on Linux systems including Debian as well. It is a versatile package manager that simplifies the process of installing and utilizing a vast array of libraries and tools that enrich your experience with Python programming. You can use pip to install, upgrade and remove packages from your system within a few minutes without installing any additional dependencies.

In this guide, you will learn:

How to Install pip on Debian 12

You can install pip on Debian 12 from:

How to Install pip on Debian 12 from Apt Package Manager

The apt package repository of Debian 12 includes the installation of pip package manager, making it easier and straightforward for you to quickly install it on the system. However, before performing the pip installation on Debian 12, you must update packages from the following command:

sudo apt update && sudo apt upgrade -y

After updating the packages, you can use the following apt command to install pip on Debian 12, where the y flag is used to automatically approve the installation on the system:

sudo apt install python3-pip -y

Once the pip installation completed on Debian 12, use the following command to check the version of pip:

pip3 --version

Note: You can use pip instead of pip3 as well.

How to Remove pip from Debian 12 Apt Repository

To remove pip from Debian 12, you can simply use the following command:

sudo apt remove python3-pip -y

How to Install pip on Debian 12 from Python

You can also download the Python script file from the official website and install the latest version of pip from there on Debian 12. This can be done from the steps given below:

Step 1: Download pip Python Script File on Debian 12

First, you have to download the python script file for pip on Debian 12 using the following command:

wget https://bootstrap.pypa.io/pip/pip.pyz

Step 2: Execute the Python Script on Debian 12

You have to execute the python script for pip on Debian 12 from python interpreter using the following command:

python3 get-pip.py

While, running the command on Debian 12, you will experience externally-manager-environment which means that you cannot execute the script outside the environment:

Step 3: Fix externally-manager-environment on Debian 12

To fix externally-manager-environment error on Debian 12, you can simply add –break-system-packages after the pip command. This will begin the installation of pip on Debian 12:

The above command successfully will successfully install the pip on Debian 12, however, you will see a warning message that “The script pip, pip3 and pip3.11 are installed in ‘home/pi/.local/bin’ location which is not on PATH”, as shown below:

Step 4: Fix “The script pip, pip3 and pip3.11 are installed in ‘home/pi/.local/bin’ location which is not on PATH” on Debian 12

To fix “The script pip, pip3 and pip3.11 are installed in ‘home/pi/.local/bin’ location which is not on PATH” error on Debian 12, you can simply move the file pip, pip3 and pip3.11 one by one to the /usr/bin location using the cp command:

sudo cp /home/username/.local/bin/pip /usr/bin

Note: Ensure replacing the username with your Pi username which is linuxhint in my case, while add pip3 and pip3.11 as well after executing the above command with pip:

Step 5: Check pip Version on Debian 12

After installing pip on Debian 12, you can confirm the installation of latest version through this method using the following command:

pip3 --version

How to Upgrade pip on Debian 12

If there is any latest version of pip available, you can simply use the following command to upgrade pip on Debian 12:

pip3 install --upgrade pip --break-system-packages

How to Use pip on Debian 12

To use pip on Debian 12 for installing packages, you can simply follow the below-given command by replacing the package_name with the package you wish to install:

pip3 install package_name --break-system-packages

How to Uninstall Package from pip on Debian 12

If you want to uninstall a package from pip on Debian 12, you can use the following command:

pip3 uninstall package_name

Conclusion

pip is a versatile package manager used for installing and managing Python packages on Linux systems. This article has provided a detailed guide on installing pip on Debian 12 using two methods: the Apt package manager and Python script. It also addresses removing pip from apt repository, updating pip, using pip for package installation and fixes to common errors that occur during the package installation. You will also find methods to quickly remove a package installed from pip on Debian 12. Following this guide, you will be able to manage your Python packages and enhance your programming experience on Debian.

About the author

Awais Khan

I'm an Engineer and an academic researcher by profession. My interest for Raspberry Pi, embedded systems and blogging has brought me here to share my knowledge with others.