How To Install python-naturalsort on Debian 9
Introduction
In this tutorial we learn how to install python-naturalsort
on Debian 9.
What is python-naturalsort
python-naturalsort is:
The
natsort.natsort()
function in thenaturalsort
package is a very simple alternative to Python’ssorted()
function that implementsnatural order sorting
_ in Python. The package is available on PyPI, so getting started is very simple:
$ pip install naturalsort $ python
from natsort import natsort versions = [‘1.8.1-r26’, ‘1.8.1-r30’, ‘2.0-r2’, ‘2.0-r7’, ‘2.0-r11’] natsort([‘my-package-%s’ % v for v in versions]) [‘my-package-1.8.1-r26’, ‘my-package-1.8.1-r30’, ‘my-package-2.0-r2’, ‘my-package-2.0-r7’, ‘my-package-2.0-r11’]
The main use case that this package was originally created for is sorting of
pathnames with versions numbers embedded in them. This is why the sorting key
defined by the naturalsort
package ignores filename extensions (not doing
so can give unexpected results).
There are three methods to install python-naturalsort
on Debian 9. 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-naturalsort 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-naturalsort
using apt-get
by running the following command:
sudo apt-get -y install python-naturalsort
Install python-naturalsort Using apt
Update apt database with apt
using the following command.
sudo apt update
After updating apt database, We can install python-naturalsort
using apt
by running the following command:
sudo apt -y install python-naturalsort
Install python-naturalsort 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 Debian. Update apt database with aptitude
using the following command.
sudo aptitude update
After updating apt database, We can install python-naturalsort
using aptitude
by running the following command:
sudo aptitude -y install python-naturalsort
How To Uninstall python-naturalsort on Debian 9
To uninstall only the python-naturalsort
package we can use the following command:
sudo apt-get remove python-naturalsort
Uninstall python-naturalsort And Its Dependencies
To uninstall python-naturalsort
and its dependencies that are no longer needed by Debian 9, we can use the command below:
sudo apt-get -y autoremove python-naturalsort
Remove python-naturalsort Configurations and Data
To remove python-naturalsort
configuration and data from Debian 9 we can use the following command:
sudo apt-get -y purge python-naturalsort
Remove python-naturalsort configuration, data, and all of its dependencies
We can use the following command to remove python-naturalsort
configurations, data and all of its dependencies, we can use the following command:
sudo apt-get -y autoremove --purge python-naturalsort
Dependencies
python-naturalsort have the following dependencies:
References
Summary
In this tutorial we learn how to install python-naturalsort
package on Debian 9 using different package management tools: apt
, apt-get
and aptitude
.