How to install pip on Debian 11

Pip is a package-management system written in Python used to install and manage software packages. It is a package management system that simplifies installation and management of software packages written in Python such as those found in the Python Package Index (PyPI). Pip is not installed by default on Debian 11.

In this guide we will learn how to install Python Pip on Debian 11 using the apt package manager.

# Prerequisites

Before proceeding, ensure that you have the following:

  • Updated Debian 11 system
  • Access to the internet so we can download the packages
  • Root access or user with sudo access

Table of content

  1. Updating the system packages
  2. Installing pip for python 3

# 1. Updating the system packages

Run this command to ensure that your system packages are up to date

sudo apt update
sudo apt -y upgrade

# 2. Installing pip for python 3

Debian 11 ships with python3 as the default python interpreter. Before installing pip, ensure that python is installed using this command:

sudo apt install python3

Then install pip

sudo apt install python3-pip

Now confirm that pip is installed:

$ pip3 --version
pip 20.3.4 from /usr/lib/python3/dist-packages/pip (python 3.9)

# 3. Installing pip for Python 2 

Python 2 is not installed by default in Debian 11. To install Python 2 and Pip 2, do the following:

Install python 2:

sudo apt install python

Then install python2 pip:

sudo apt install -y python-pip

Then verify the installation with this command:

<meta charset="utf-8">$ pip --version
pip 20.3.4 from /usr/lib/python2.7/dist-packages (python 2.7)

# 4. Using python pip

Pip is used to manage python modules on the system. The python modules will be installed globally. You can also install these modules using the apt package manager.

If the module you are installing is used for a specific limited purpose, it is advisable to install and manage them using virtual environments. Python Virtual Environments allows you to install Python modules in an isolated location for a specific project, rather than being installed globally. This way you do not have to worry about affecting other Python projects.

In this section we will explore pip useful commands. Pip allows you to install packages from PyPI, version control packages, local projects, and from distribution files.

# Installing Packages with Pip

To install a package with pip, use pip install command. This will install the latest version by default.

pip3 install docker-compose

If you want to install a specific version of a package, specify it like this:

pip3 install docker-compose==1.29.0

# Using requirements file to install pip packages

If you have a number of packages to install with a specific version for each package, you can add them to a file called requirements.txt. You can add the packages in the formatt package==version like


Use the following command to install a list of requirements specified in a file:

pip3 install -r requirements.txt

# Listing Installed Packages

Use this command to list installed packages. This will list each package and the version installed for that package.

pip3 list


$ pip3 list | grep docker
docker              5.0.3
docker-compose      1.29.2
dockerpty           0.4.1

A common way to list the packages is using a format that can be added to a requirements.txt file. Use this command to list them in that format:

pip3 freeze


$ pip3 freeze | grep docker

# Upgrading installed package

Use this command to upgrade installed package

pip3 install --upgrade package_name


pip3 install --upgrade docker-compose

# Uninstalling Packages With Pip

To uninstall a package run:

pip3 uninstall package_name


<meta charset="utf-8">pip3 <meta charset="utf-8">uninstall docker-compose

# Conclusion

In this guide, you have learned how to install pip on your Debian 11 system and how to manage Python packages using pip. For more information about pip, visit the pip user guide page.

comments powered by Disqus
Citizix Ltd
Built with Hugo
Theme Stack designed by Jimmy