Hi all, New to Balena
I’m trying to setup a Pi3 to use a I2C device and CANBUS libraries however my python scripts just crash with ImportError: No module named XXXX
on lines import smbus
or import can
.
I’ve tried installing them in the Dockerfile, the requirements.txt file and even tried using different base images but no luck, all I2C example projects are older and still using resin code.
Here is my Dockerfile.template
file, modified from the getting started example.
# base-image for python on any machine using a template variable,
# see more about dockerfile templates here: https://www.balena.io/docs/learn/develop/dockerfile/
#FROM balenalib/%%BALENA_MACHINE_NAME%%-python:3-stretch-run
FROM balenalib/raspberrypi3-debian-python:latest
# Base OS doesn’t seem to make any difference
# use 'install_packages' if you need to install dependencies,
RUN install_packages apt-utils
RUN install_packages i2c-tools
RUN install_packages python-smbus
# Set our working directory
WORKDIR /usr/src/app
# Copy requirements.txt first for better cache on later pushes
COPY requirements.txt requirements.txt
#Currently empty
# pip install python deps from requirements.txt on the resin.io build server
RUN pip install -r requirements.txt
# This will copy all files in our root to the working directory in the container
COPY . ./
# Enable udevd so that plugged dynamic hardware devices show up in our container.
#ENV UDEV=1
# CMD will run when container starts up on the device
CMD ["python","-u","app/HelloWorld.py"]
# “import smbus” inside script, throws error