How to Install pip on Debian?

Photo of author

By admin

Debian has been in existence since 1993, and since then, it has been around and is going to be around for a long while. Known for its stability and reliability, this OS has always proved worthy of its widespread use. If you are a programmer, there is no doubt that you must have Python installed on your Debian OS.

Python, being a programming language used for varied purposes, is used by almost every programmer at least once in his life. If you have also thrown in the combination of Python and Debian, you must be wondering how to install pip on Debian.

Pip i.e. package installer for Python is written in Python and used to install and manage software packages. Python has a public online repository from where you can download packages that contain all the important files required for running modules. The modules are codes that Python users use to write programs. However, it can be a headache to install and manage all the packages. So, let pip do it for you.

This is a comprehensive guide that has got everything you need to know about how to install pip on Debian. It covers installing Pip for Python 2 and Python 3 series for Debian 9 and Debian 10.

Prerequisites for Installing pip

You must ensure that you have the below-mentioned prerequisites ready before you know how to install pip on Debian.

The requirements are:

  • A Debian 9 or 10 server
  • Log in as a sudo privileged user
  • Apt package manager

Installing pip on Debian 9 and 10

The process to install pip on both Debian 9 and 10 is similar for the series Python 2 and Python 3. Here is how to install pip on Debian.

Installing pip for Python 2

The steps mentioned below will get pip installed for Python 2.

Update the package with:

sudo apt update

This command will install pip and all its dependencies for Python 2:

sudo apt install python-pip

After the completion of installation, verify it with the command given below to check the version.

pip –version

As per the version of your Python, the version may be different, but the result will be somewhere near to:

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

And you are done. Just a few commands and your pip for Python is installed for Debian 9 and 10.

Installing Pip for Python 3

Follow the steps to install pip for Python 3 on Debian 9 and 10.

Update the package:

sudo apt update

Install pip and all of its dependencies for Python 3:

sudo apt install python3-pip

Check the installation. The command will print the pip version.

pip3 –version

It will return something like, with a different version, maybe, depending on your Python version

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

The installation of the pip for Python 3 is incomplete.

Using pip on Debian

Merely installing pip will not work for you. Therefore, you must know how to use it for your purpose. Using pip is even simpler than installing it. It is the beauty of command-line tools; they are simple. For Python users, the most common commands to use pip on Debian are given below.

You must be aware of the package to be installed. The Python Package Index has numerous packages listed on it. You can search and install them very easily and quickly with pip.

First of all, search the package in PyPI:

pip search “search_query”

If you have learned about the package you want to install, use the following command:

pip install <package name>

Uninstalling a package is as easy as installing it. You can uninstall it with the help of:

pip uninstall package_name

You can also list down the list of packages that are installed on your Debian system, try:

pip list

If you want to see the list of installed packages and their versions in a file, use the command:

pip freeze > requirements.txt

When you are using several packages, it is hard to keep on every one of them and to check which one of those are outdated; you can use the following command:

pip list –o

or, run

pip list –outdated

These common commands will help you get started with pip.

Why is pip Used So Widely Among Python Users?

There is no single reason for its popularity. Though, the main reasons are:

Access to Various Third-Party Modules: If you are a Python user, you know that Python comes with a set of basic packages which are not enough for working on all projects. Python Package Index has a list of thousands of packages that a Python user can download and use. These packages contain numerous modules which contain code essential for Python programmers.

The open-source community continually updates the repository for making the modules available to other Python users. The repository contains several third-party modules, which aids the programmers. They can choose and download a package very easily using pip. The process is simple and can be easily used by a novice as well.

Python’s Virtual Environment: This is another big reason for using pip. It allows for the installation of a Python module in an isolated environment different from your global setup. For instance, if you want to work on a separate project and want a module solely for it, you can download it separately, and it will not be applicable for global projects.

There will be separate files for separate projects. You can create several Python environments. Python 3 allows it with the venv module in Python 3 library.

Conclusion

The number of modules on PyPI is numerous. They make working easier and support many functions ranging from supporting website development, application development, high-performance software, administration, etc. Besides, modules allow programmers to work efficiently without wasting time on writing codes that are readily available.

Pip facilitates installing and managing these modules easily with its simple command process. Whether you have Debian 9 or Debian 10, you are covered here whether you are using Python 2 series or Python 3 series. This guide answers how to install pip on Debian, and also guides you about how to use it. All you need to do is follow the commands and you will face no problem installing pip on Debian.

Leave a Comment