docformatter command not found

In this troubleshooting guide we learn how to fix docformatter command not found error message

Introduction

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

docformatter: command not found

or when using sudo you get the following error message

sudo: docformatter: command not found

Solutions to docformatter: command not found

How To Fix docformatter: command not found in Ubuntu / Debian / Kali Linux / Raspbian

In Ubuntu docformatter is provided by python3-docformatter package.

python3-docformatter is:

Docformatter currently automatically formats docstrings to follow a subset of the PEP 257 conventions.

Below are the relevant items quoted from PEP 257:

  • For consistency, always use triple double quotes around docstrings,
  • Triple quotes are used even though the string fits on one line,
  • Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description,
  • Unless the entire docstring fits on a line, place the closing quotes on a line by themselves.

Docformatter also handles some of the PEP 8 conventions:

  • Don’t write string literals that rely on significant trailing whitespace Such trailing whitespace is visually indistinguishable and some editors (or more recently, reindent.py) will trim them.

This package installs the library for Python 3.

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

sudo apt-get -y install python3-docformatter

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

You can also use apt command to install python3-docformatter.

sudo apt -y install python3-docformatter

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

sudo aptitude install python3-docformatter

Summary

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