2to3 command not found

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

Introduction

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

2to3: command not found

or when using sudo you get the following error message

sudo: 2to3: command not found

Solutions to 2to3: command not found

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

In Ubuntu 2to3 is provided by 2to3 package.

2to3 is:

2to3 is a Python program that reads Python 2.x source code and applies a series of fixers to transform it into valid Python 3.x code. The standard library contains a rich set of fixers that will handle almost all code. 2to3 supporting library lib2to3 is, however, a flexible and generic library, so it is possible to write your own fixers for 2to3. lib2to3 could also be adapted to custom applications in which Python code needs to be edited automatically.

This package is a dependency package, which depends on Debian’s default Python 3 2to3 version (currently v3.10).

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

sudo apt-get -y install 2to3

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

You can also use apt command to install 2to3.

sudo apt -y install 2to3

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

sudo aptitude install 2to3

Summary

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