How To Install python-pathlib on Ubuntu 18.04

In this tutorial we learn how to install python-pathlib on Ubuntu 18.04. python-pathlib is set of Python 2 classes to handle filesystem paths

Introduction

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

What is python-pathlib

python-pathlib is:

Pathlib offers a set of classes to handle filesystem paths. It offers the following advantages over using string objects:

  • No more cumbersome use of os and os.path functions. Everything can be done easily through operators, attribute accesses, and method calls.
  • Embodies the semantics of different path types. For example, comparing Windows paths ignores casing.
  • Well-defined semantics, eliminating any warts or ambiguities (forward vs. backward slashes, etc.).

This is the Python 2 version of the package.

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

sudo apt-get -y install python-pathlib

Install python-pathlib Using apt

Update apt database with apt using the following command.

sudo apt update

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

sudo apt -y install python-pathlib

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

sudo aptitude -y install python-pathlib

How To Uninstall python-pathlib on Ubuntu 18.04

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

sudo apt-get remove python-pathlib

Uninstall python-pathlib And Its Dependencies

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

sudo apt-get -y autoremove python-pathlib

Remove python-pathlib Configurations and Data

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

sudo apt-get -y purge python-pathlib

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

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

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

References

Summary

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