Python: how to install Pip on Debian 11?

installing Pip on Debian 11

On Debian 11, you need to install Pip to benefit from Python-coded packages on your Linux machine. After installing the Pip package manager, you'll be able to easily install Python packages and libraries: a must for anyone working with Python.

The Pip package manager settles on Debian 11It's also available for other versions of Debian, as well as other Linux distributions: Ubuntu, Rocky Linux, Fedora, etc. By way of comparison, it's the equivalent of Composer for PHP.

Before getting started, you should know that there is a version of Pip for Python 3 and a version of Pip for Python 2. We'll look at both to cover as many needs as possible.

Note The "pypi.org" website references Python packages and currently boasts over 400,000 projects.

1. Install Pip for Python 3

To begin with, let's take a look at how to install Pip on Debian 11 for use with Python 3the latest version of the Python language. You'll see that there's little difference between the two.

From an account that has "sudo" access (or the root account directly), update the package cache and install the "python3-pip" package, as follows:

sudo apt-get update
sudo apt-get install python3-pip

Press "o" to launch the installation on your machine.

Installing Pip for Python 3 on Debian 11

When it's done, you can view the installed version with this command:

pip3 -V

On my bike, the following result is returned:

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

The version may vary over time, but in the end Pip is installed on your Debian machine! Next, you'll probably how to install a Python package using Pip?

You must use a command that respects this syntax:

sudo pip3 install  <package name

To install a specific version of a package :

sudo pip3 install ==

Sometimes, a list of dependencies is provided in a " requirements.txt" . Pip can be told to read the contents of this file directly, after checking the contents of course!

sudo pip3 install -r requirements.txt

Finally, you can list installed packages at any time with the following command:

pip3 list

2. Install Pip for Python 2

Python 2 is no longer maintained, but is still usable, and the Pip package manager is still available for Debian. Although it's recommended to use Python 3, here's how to benefit from Pip for Python 2, as some applications still require this version.

Update the package cache and install the "python2" package:

sudo apt-get update 
sudo apt-get install python2

Next, you need to download the "get-pip.py" file, which we'll store temporarily in "/tmp/":

curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o /tmp/get-pip.py

Then, starting from Python 2, you need to run the :

sudo python2 /tmp/get-pip.py

As I said, Python 2 is no longer maintained, so a warning is displayed, but the installation goes ahead anyway.

Python 2 Debian 11

When installation is complete, you can check the version installed:

pip -V

An output similar to this is returned in the Debian 11 console:

pip 20.3.4 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)

Python 2 is now available on Debian 11, alongside Python 3. In both cases, the Pip package manager is ready for use!

To install a Python2 package with Pip, simply replace the "pip3" command with "pip2". on the same principle as the previous examples.

3. Conclusion

After reading this article, you will be able toinstalling Pip on Debian 11 to enjoy Python 3 and/or Python 2 on your server or workstation!

Resources :

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *