python-modernize command not found

In this troubleshooting guide we learn how to fix python-modernize command not found error message

Introduction

When you run more command in linux terminal / console, you get the following error message

python-modernize: command not found

or when using sudo you get the following error message

sudo: python-modernize: command not found

Solutions to python-modernize: command not found

How To Fix python-modernize: command not found in Ubuntu / Debian / Kali Linux / Raspbian

In Ubuntu python-modernize is provided by modernize package.

modernize is:

This library is a very thin wrapper around lib2to3 to utilize it to make Python 2 code more modern with the intention of eventually porting it over to Python 3.

This package installs the python-modernize command line tool. It works like 2to3. It does not guarantee, but it attempts to spit out a codebase compatible with Python 2.6+ or Python 3. The code that it generates has a runtime dependency on six, unless the –no-six option is used. Version 1.9.0 or later of six is recommended. Some of the fixers output code that is not compatible with Python 2.5 or lower.

To fix this problem, we can install more using the command below.

sudo apt-get -y install modernize

This command might take some time to finish depending on your machine internet connection.

You can also use apt command to install modernize.

sudo apt -y install modernize

Or if you have aptitude installed you can use the following command.

sudo aptitude install modernize

Summary

In this tutorial we learn how to fix python-modernize command not found error in Ubuntu / Debian / Kali Linux or Raspbian distribution.