natsort command not found
Introduction
When you run more command in linux terminal / console, you get the following error message
natsort: command not found
or when using sudo you get the following error message
sudo: natsort: command not found
Solutions to natsort: command not found
How To Fix natsort: command not found in Ubuntu / Debian / Kali Linux / Raspbian
In Ubuntu natsort is provided by python3-natsort package.
python3-natsort is:
natsort lets you apply natural sorting to your sequences easily, for example:
from natsort import natsorted a = [‘a2’, ‘a9’, ‘a1’, ‘a4’, ‘a10’] data = [[‘a1’, ‘a5’], [‘a1’, ‘a40’], [‘a10’, ‘a1’], [‘a2’, ‘a5’]] natsorted(a) [‘a1’, ‘a2’, ‘a4’, ‘a9’, ‘a10’ natsorted(data) [[‘a1’, ‘a5’], [‘a1’, ‘a40’], [‘a2’, ‘a5’], [‘a10’, ‘a1’]]
natsort identifies the numbers and sorts them separately from strings.
natsort comes with a shell script to use natural sorting in shell scripts. You can also execute natsort from the command line with Python -m natsort.
There exists another natural sorting package for Python called python-naturalsort. You may prefer that package if you wish to only sort version numbers.
This is the Python 3 version of the package.
To fix this problem, we can install more using the command below.
sudo apt-get -y install python3-natsort
This command might take some time to finish depending on your machine internet connection.
You can also use apt command to install python3-natsort.
sudo apt -y install python3-natsort
Or if you have aptitude installed you can use the following command.
sudo aptitude install python3-natsort
Summary
In this tutorial we learn how to fix natsort command not found error in Ubuntu / Debian / Kali Linux or Raspbian distribution.