Pip is a package management system that allows you to install Python packages. With pip, you can install packages from the Python Package Index (PyPI) and other repositories.

In this guide, we will explain how to install pip for both Python 2 pip and Python 3 pip3 on Debian 10, Buster, using the apt package manager. We will also show you how to install and manage Python packages with pip.

Installing pip for Python 3

Perform the following steps as a user with sudo privileges to install Pip for Python 3 on Debian 10:

  1. Start by updating the package list:
    sudo apt update
  2. Install pip for Python 3 and all of its dependencies with the following command:
    sudo apt install python3-pip
  3. Print the pip3 version to verify the installation:
    pip3 --version

    The version number may be different, but it will look something like the one below:

    pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7)

Installing pip for Python 2

The following steps describe how to install Pip for Python 2 on Debian systems:

  1. Start by updating the packages index:
    sudo apt update
  2. Install pip for Python 2 and all of its dependencies:
    sudo apt install python-pip
  3. Verify the installation by issuing the following command which will print the pip version:
    pip --version

    The version number may vary, but it will look something like this:

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

Using Pip

In this section, we will talk about the basic pip commands. With pip, you can install packages from PyPI, version control, local projects, and from distribution files but in most cases, you will install packages from PyPI.

If you want to install a python module globally, you should prefer to install it as a package using the apt manager. Use pip to install python modules globally only if there is no package available.

Usually, you would use pip inside a virtual environment only. Python Virtual Environment 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.

Let’s say you want to install a package named urllib3, you can do that by issuing the following command:

pip install urllib3

urllib3 is a powerful HTTP client for Python.

Uninstalling a package:

pip uninstall package_name

Searching packages from PyPI:

pip search "search_query"

Listing installed packages:

pip list

Listing outdated packages:

pip list --outdated

Conclusion

We have shown you how to install pip on your Debian system and how to manage Python packages using pip. For more information about pip, check the pip user guide.

If you have any questions or feedback, feel free to comment below.