Adding a python3 module to ElkOS


I would like to use I2C from the RPi.

I’m not a Python expert, but it seems as though Python would be easiest way to debug messages between my devices. I’m not controlling a display, so I don’t think that the luma module (mentioned in another thread) is the correct way to do it.

In python3, I got into the help area and looked for modules supporting i2c, using help(), and then typing modules i2c. It listed 2, including one helpfully titled “i2c”. Sounds promising.

But when I tried to get help on that module, an error message appears on the terminal screen:

problem in i2c - ModuleNotFoundError: No module named 'smbus'

How do I use i2C from Python? How do I add the smbus module?


Hi @rcohen,
on the development versions of Elk - which should be the one that you’re using - you have pip available so you should just be able to pip3 install smbus to get it (be sure to use Python3 as the Python 2 version on Elk is limited).

When you’ll have to then generate a full image that includes the package for an industrial product, it is possible to automate the process by writing a simple Yocto recipe.

Hi @Stefano,

Thanks. I found “(sudo) pip3 install smbus” after some Google searching.

Much appreciation.