Introduction

Pip stands for Preferred Installer Program or Pip Installs Packages. Pip 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

To complete the installation of Pip for Python 2 on your Debian system, follow the steps below:

1. Update the packages index:

sudo apt update

2. Install pip using the command:

sudo apt install python-pip Enter Y to continue and let it finish.

3. Verify your installation with the following command:

pip --version

The output should look like the example below, but your version may vary:

Debian terminal showing the version of pip.

Install Pip for Python 3

The procedure for installing pip for Python 3 is similar to the one for Python 2. Follow the steps below:

1. Update the packages index:

sudo apt update

2. Install pip for Python 3 using the command:

sudo apt install python3-pip Enter Y to continue and let the process finish.

3. Verify your Python installation with the following command:

pip3 --version

The output should like similar to the example below, but your version may vary:

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

Using Pip on Debian

Pip Commands

Once you successfully install pip, you can start using pip to install packages. Some of the most common pip commands are listed below.

To install a package, enter:

pip install package_name

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

The list of pip packages in the Debian terminal
To output currently installed python packages and their versions into a file:

pip freeze > requirements.txt

To list all the packages that are outdated, run one of these two commands:

pip list -o

or

pip list --outdated

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 will find thousands of third-party modules suitable for Python.

Using the Pip package manager, the 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, many other modules do not come as standard. This practice is an efficient arrangement, because as users select what they need with the Pip manager, Python stays compact.  Users can always quickly expand Python with the easy availability of an ever-evolving repository of free packages.

Another Pip’s helpful trait is the ease of its command-line functions to install those packages.

Python Virtual Environment

Once you install Pip, you can start exploring 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 is a leap ahead for version control while facilitating access to the necessary packages for each of your Python projects.

Conclusion

This guide showed you how to install pip for Python 2 and 3 on Debian 9. We also listed most useful pip commands to get you started.

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

NumPy is a library for the Python programming language, adding support for large, multi-dimensional arrays and matrices. Check out our guide and learn how to install NumPy using PIP.


Next you should also read