How To Install python-apt on Ubuntu 20.04

In this tutorial we learn how to install python-apt on Ubuntu 20.04. python-apt is Python interface to libapt-pkg Python interface to libapt-pkg Python interface to libapt-pkg

Introduction

In this tutorial we learn how to install python-apt on Ubuntu 20.04.

What is python-apt

python-apt is:

The apt_pkg Python interface will provide full access to the internal libapt-pkg structures allowing Python programs to easily perform a variety of functions, such as:

  • Access to the APT configuration system
  • Access to the APT package information database
  • Parsing of Debian package control files, and other files with a similar structure

The included ‘aptsources’ Python interface provides an abstraction of the sources.list configuration on the repository and the distro level.

Package: python-apt Architecture: amd64 Version: 2.0.0ubuntu0.20.04.3 Multi-Arch: allowed Priority: optional Section: universe/python Origin: Ubuntu Maintainer: Ubuntu Developers [email protected] Original-Maintainer: APT Development Team [email protected] Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 720 Provides: python2.7-apt Depends: python2 (« 2.8), python2 (>= 2.7~), python2:any (« 2.8), python2:any (>= 2.7~), libapt-pkg6.0 (>= 1.9.11~), libc6 (>= 2.14), libgcc-s1 (>= 3.0), libstdc++6 (>= 5.2), python-apt-common, gnupg, dirmngr | gnupg (« 2) Recommends: lsb-release, iso-codes, xz-utils Suggests: python-apt-dbg, python-apt-doc, apt Breaks: apt-forktracer (« 0.3), apt-listchanges (« 2.85), apt-p2p (« 0.1.6), apt-xapian-index (« 0.25), aptdaemon (« 1.1.1+bzr982-0ubuntu31), aptoncd (« 0.1.98+bzr117), bcfg2 (« 1.0.1), bzr-builddeb (« 2.4), computer-janitor (« 1.14.1-1+), debdelta (« 0.41+), debpartial-mirror (« 0.2.98), debsecan (« 0.4.15), gdebi (« 0.6.1), germinate (« 1.21), gnome-codec-install (« 0.4.5), mini-dinstall (« 0.6.28), packagekit-backend-apt (<= 0.4.8-0ubuntu4), python-cdd (« 0.0.10), python-dogtail (« 0.6.1-3.1+), python-software-properties (« 0.70.debian-1+), rebuildd (« 0.3.9), software-center (« 1.1.21debian2), tla-buildpackage (« 0.9.14), ubuntu-dev-tools (« 0.93debian1), unattended-upgrades (« 0.42debian2), update-manager (« 0.200.2-1), update-notifier (« 0.99.3debian9), wajig (« 2.0.46) Filename: pool/universe/p/python-apt/python-apt_2.0.0ubuntu0.20.04.3_amd64.deb Size: 154548 MD5sum: 2d358547a462844157644b20837edd95 SHA1: 063affceec828eff5f7c52c7bc95100de3847ab7 SHA256: 57219805f3e0e7aeeacc9028f1e623c099b8a6619e29b4811fc5afddb35e1a49 SHA512: 23aaa0cf8355d8a3a976d001ee51fc1ce394a457d7f7d9e613b26ad1096ab66710ba442c481c633be0aaa4cf5e22d26ca7fa83e260a536b6cf5f37913ca101fa Description-en: Python interface to libapt-pkg The apt_pkg Python interface will provide full access to the internal libapt-pkg structures allowing Python programs to easily perform a variety of functions, such as:

  • Access to the APT configuration system
  • Access to the APT package information database
  • Parsing of Debian package control files, and other files with a similar structure

The included ‘aptsources’ Python interface provides an abstraction of the sources.list configuration on the repository and the distro level.

Package: python-apt Architecture: amd64 Version: 2.0.0 Multi-Arch: allowed Priority: optional Section: universe/python Origin: Ubuntu Maintainer: Ubuntu Developers [email protected] Original-Maintainer: APT Development Team [email protected] Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 719 Provides: python2.7-apt Depends: python2 (« 2.8), python2 (>= 2.7~), python2:any (« 2.8), python2:any (>= 2.7~), libapt-pkg6.0 (>= 1.9.11~), libc6 (>= 2.14), libgcc-s1 (>= 3.0), libstdc++6 (>= 5.2), python-apt-common, gnupg, dirmngr | gnupg (« 2) Recommends: lsb-release, iso-codes, xz-utils Suggests: python-apt-dbg, python-apt-doc, apt Breaks: apt-forktracer (« 0.3), apt-listchanges (« 2.85), apt-p2p (« 0.1.6), apt-xapian-index (« 0.25), aptdaemon (« 1.1.1+bzr982-0ubuntu31), aptoncd (« 0.1.98+bzr117), bcfg2 (« 1.0.1), bzr-builddeb (« 2.4), computer-janitor (« 1.14.1-1+), debdelta (« 0.41+), debpartial-mirror (« 0.2.98), debsecan (« 0.4.15), gdebi (« 0.6.1), germinate (« 1.21), gnome-codec-install (« 0.4.5), mini-dinstall (« 0.6.28), packagekit-backend-apt (<= 0.4.8-0ubuntu4), python-cdd (« 0.0.10), python-dogtail (« 0.6.1-3.1+), python-software-properties (« 0.70.debian-1+), rebuildd (« 0.3.9), software-center (« 1.1.21debian2), tla-buildpackage (« 0.9.14), ubuntu-dev-tools (« 0.93debian1), unattended-upgrades (« 0.42debian2), update-manager (« 0.200.2-1), update-notifier (« 0.99.3debian9), wajig (« 2.0.46) Filename: pool/universe/p/python-apt/python-apt_2.0.0_amd64.deb Size: 154456 MD5sum: 82974f01af6eea6f7c07d0b4472fe98b SHA1: d0a29118a3ebef523949209dec0d9560881ed577 SHA256: 1fb8df3030722e1a8da6a2e32b000f5ef020ec3f09fec53bb9ea239a2b24a3a2 Description-en: Python interface to libapt-pkg The apt_pkg Python interface will provide full access to the internal libapt-pkg structures allowing Python programs to easily perform a variety of functions, such as:

  • Access to the APT configuration system
  • Access to the APT package information database
  • Parsing of Debian package control files, and other files with a similar structure

The included ‘aptsources’ Python interface provides an abstraction of the sources.list configuration on the repository and the distro level.

There are three methods to install python-apt on Ubuntu 20.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-apt 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-apt using apt-get by running the following command:

sudo apt-get -y install python-apt

Install python-apt Using apt

Update apt database with apt using the following command.

sudo apt update

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

sudo apt -y install python-apt

Install python-apt 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-apt using aptitude by running the following command:

sudo aptitude -y install python-apt

How To Uninstall python-apt on Ubuntu 20.04

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

sudo apt-get remove python-apt

Uninstall python-apt And Its Dependencies

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

sudo apt-get -y autoremove python-apt

Remove python-apt Configurations and Data

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

sudo apt-get -y purge python-apt

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

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

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

References

Summary

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