How To Install python-mode on Ubuntu 18.04

In this tutorial we learn how to install python-mode on Ubuntu 18.04. python-mode is Python mode for GNU Emacs and XEmacs

Introduction

In this tutorial we learn how to install python-mode on Ubuntu 18.04.

What is python-mode

python-mode is:

Provides a major mode for GNU Emacs and XEmacs to edit, debug, and develop Python programs and doctests.

If you install this with XEmacs 21, it will replace the included python-mode.el, which may or may not be a more recent version (use “C-h v py-version” to compare).

Since this package automagically loads after Python mode shipped with GNU emacs >= 22, installation of this package makes python-mode’s mode the default for editing Python code in emacs.

There are three methods to install python-mode on Ubuntu 18.04. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install python-mode Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update

After updating apt database, We can install python-mode using apt-get by running the following command:

sudo apt-get -y install python-mode

Install python-mode Using apt

Update apt database with apt using the following command.

sudo apt update

After updating apt database, We can install python-mode using apt by running the following command:

sudo apt -y install python-mode

Install python-mode Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.

sudo aptitude update

After updating apt database, We can install python-mode using aptitude by running the following command:

sudo aptitude -y install python-mode

How To Uninstall python-mode on Ubuntu 18.04

To uninstall only the python-mode package we can use the following command:

sudo apt-get remove python-mode

Uninstall python-mode And Its Dependencies

To uninstall python-mode and its dependencies that are no longer needed by Ubuntu 18.04, we can use the command below:

sudo apt-get -y autoremove python-mode

Remove python-mode Configurations and Data

To remove python-mode configuration and data from Ubuntu 18.04 we can use the following command:

sudo apt-get -y purge python-mode

Remove python-mode configuration, data, and all of its dependencies

We can use the following command to remove python-mode configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge python-mode

References

Summary

In this tutorial we learn how to install python-mode package on Ubuntu 18.04 using different package management tools: apt, apt-get and aptitude.