Introduction

Pip means “preferred installer program” or “Pip installs packages.” It simplifies the installation and management of software packages written in Python. Python’s versatility makes it a useful system not only for a programming language, but also for data analysis, AI, and back-end research and development.

In this tutorial, learn how to install Pip for Python 2 & 3 on Debian 9.

Installing Pip on Debian 9 to manage python

Prerequisites

Installing Pip on Debian

Install Pip for Python 2

1. Update the packages index:

sudo apt update

2. Install Pip using the command:

sudo apt install python-pip

3. Verify your installation with the following command:

pip --version

The output should like the example below, but your version may vary:
pip 9.0.0 from /usr/lib/python3/dist-packages (python 2.4)

Install Pip for Python 3

1. Update the packages index:

sudo apt update

2. Install Pip for Python 3 using the command:

sudo apt install python3-pip

3. Verify your Python installation with the following command:

pip3 --version

The output should like the example below, but your version may vary:
pip 9.0.0 from /usr/lib/python3/dist-packages (python 3.4)

Now you are ready to install any package from the Python Package Index.

Using Pip on Debian

Pip Commands

To uninstall a package run:

pip uninstall package_name

To search packages from PyPI:

pip search "search_query"

To list packages in the current environment:

pip list

To output currently installed python packages and their versions:

pip freeze > requirements.txt

To freeze the packages and their current version:

pip freeze > filename

To list all the packages that are outdated:

list -o or pip list --outdated command

Pip Third-Party Modules

Python packages are made up of modules (useful code) that expand and augment the uses for Python programming language. In the Python Package Index (PyPI), you’ll find thousands of third-party modules suitable for Python.

Using the Pip package manager, installation of any module is a straightforward process.

Web developers are steadily building on the PyPI repository, offering the packages of modules to other Python users through this open-source project.

This is vital because although Python comes with some basic packages, most of the larger and the less widely used modules do not come standard. This is an efficient arrangement, because as users select just what they need with the Pip manager, Python stays compact, yet with the easy availability of an ever-evolving repository of free packages.

Another of Pip’s helpful traits is the ease of its command line function to install those packages.

Python Virtual Environment

Once you install Pip, you’ll want to explore and start using Python’s Virtual Environment. This feature allows for the installation of Python modules in a separate area for a given task, rather than a global setup. Now you have a way to isolate a particular space on your server for a given Python project, with its own scripts and a unique set of dependencies that will not overlap onto other projects.

There is no limit to the number of Python environments you can set up. Each one corresponds to a folder on your Debian 9 server.

Setting up these programming environments is a straightforward job with the venv module in the Python 3 library.

Now that Python 3 offers this method of isolating projects on your server, you can keep your system files, and your project files distinct and organized. It’s a leap ahead for version control. And it facilitates access to the necessary packages for each of your Python projects.

Conclusion

Installing Pip on your Debian 9 system and managing Python packages pays off in an enhanced organization of your coding projects.

Pip supports high-performance software and website development, system administration, scientific research, statistical analysis, and so much more.

For more information about Pip, check Pip’s online User Guide.