How to fix Raspberry Pi i2cdetect: command not found

Problem:

When trying to detect I2C devices on the Raspberry Pi (Raspbian) using i2cdetect, you see the following error:

$ i2cdetect
bash: i2cdetect: command not found

Solution

InstallĀ i2c-tools using

sudo apt -y install i2c-tools

After installingĀ i2c-tools , you can useĀ i2cdetect and other related tools such as i2cget.