kernprof command not found

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

Introduction

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

kernprof: command not found

or when using sudo you get the following error message

sudo: kernprof: command not found

Solutions to kernprof: command not found

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

In Ubuntu kernprof is provided by python3-line-profiler package.

python3-line-profiler is:

LineProfiler can be given functions to profile, and it will time the execution of each individual line inside those functions. In a typical workflow, one only cares about line timings of a few functions because wading through the results of timing every single line of code would be overwhelming. However, LineProfiler does need to be explicitly told what functions to profile.

If you are using IPython, there is an implementation of an %lprun magic command which will let you specify functions to profile and a statement to execute.

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

sudo apt-get -y install python3-line-profiler

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

You can also use apt command to install python3-line-profiler.

sudo apt -y install python3-line-profiler

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

sudo aptitude install python3-line-profiler

Summary

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