How To Install Pip On Debian – [2 Easy Ways]

In Python, tools for web frameworks (Flask, Django), data analysis (NumPy, Pandas), or machine learning (TensorFlow, scikit-learn) are provided through external packages. Pip is the tool that automates the process of downloading and integrating these packages into your Python environment.

Debian-based Linux systems provide an enterprise-grade foundation for Python and Pip by combining stable dependency management, secure package isolation, ABI-compatible library integration, and reproducible virtual environments.

2 Ways to Install Pip on Debian

Pip features include automated dependency resolution, version management, virtual environment integration, package caching, configuration customization, and secure installation from PyPI or custom repositories. This guide will discuss two ways to install it on Debian, along with some of its basic commands:

1: Through Debian Default Package Installer

The first method to install pip is using the apt package installer, and for that, execute the following command:

sudo apt install python3-pip

Installing pip on Debian via apt package installer

Next, verify the pip installation by checking its version by executing:

pip3 --version

Verifying Pip version on Debian

2: Through Python Script File

Another way to install pip is by using its Python script, and for that, first download it by executing the command below:

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

Downloading Python script for installing pip on Debian

Next, install the virtual environment for pip to avoid the error of the externally managed environment, as it may overwrite packages that the OS or apt needs. So, to install a Python virtual environment, execute:

sudo apt install python3-venv

Installing Python virtual environment for installing pip on Debian

Next, create the virtual environment and afterwards activate it by using the commands below:

python3 -m venv envforpip
source envforpip/bin/activate

Creating and activating Python virtual environment for pip on Debian

Now install pip on Debian via Python script file by executing:

python3 get-pip.py

Installing pip on Debian from its script file

Next, verify the installation by checking the version:

pip3 --version

Verifying Pip version on Debian

Alternatively, to install Pip on Debian without creating a virtual environment, execute the command below, as it overrides the protection that prevents Pip from writing to/usr/lib/python3.x/site-packages. However, it can break system dependencies, for example, like upgrade requests, urllib3, or cryptography via pip, system tools like apt or software-properties might stop working:

sudo python3 get-pip.py --break-system-packages

Basic Commands for Pip Package Installer

To get started with the pip package installer, here are some of the beginner-level commands along with their description in the following table:

CommandPurpose / Description
pip install [package-name]Installs a package from the Python Package Index (PyPI).
pip install [package-name]==[version]Installs a package version that is specified
pip install –upgrade [package-name]Updates the specified package to the latest or more recent version available.
pip uninstall [package-name]Uninstalls a package.
pip show [package-name]Displays detailed information about an installed package.
pip listProvides a list of all the installed packages via pip.
pip list –outdatedShows all packages that have newer versions available.
pip freezeOutputs installed packages in requirements.txt format.
pip install -r requirements.txtInstalls packages listed in a requirements.txt file.
pip checkChecks for broken dependencies among installed packages.
pip cache dirShows the location of pip’s cache directory.
pip cache listLists packages currently cached.
pip cache purgeClears up all pip cache data.
pip show –files [package-name]Shows all the installed files for the given package.
pip config listLists all pip configuration settings.
pip config get <key>Gets the value of a pip configuration setting.
pip config set <key> <value>Sets a pip configuration option.
pip install –user [package-name]Installs the package for the current user only.
pip install –upgrade pipUpgrades pip itself to the latest version.
pip install .Installs a local package from the current directory.
pip install –no-cache-dir [package-name]Installs a package without using the cache.
pip debugDisplays comprehensive debug data.
pip helpShows general or command-specific help.
python -m pip install [Package-file -name]To install a package from its distribution file.
pip install –break-system-packages [package-name]installs packages even if it may overwrite system packages.

Conclusion

Pip is a package management system for Python, used to install, update, and manage third-party libraries and dependencies that are not part of Python’s standard library. This guide discussed two ways to install pip on Debian, which include: using the apt package installer and its Python script, along with some of the basic commands for using pip.

 

Index
Scroll to Top