Closed Ed1ks closed 3 months ago
Ok after hours of testing different dependencys because I thought there is something needed like libgpio, rpigpio, gpiod or something, I finally did find out, it was because I run code without root permission 🙈. Everyone who want to access gpio with gpiozero inside a docker container on a raspberry pi 5: Dockerfile example:
FROM python:3.11-slim-bullseye
ENV PYTHONUNBUFFERED=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PYTHONDONTWRITEBYTECODE=1
# Set the working directory inside the container
WORKDIR /app
# install
RUN apt-get update && apt-get install -y --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements.txt to the container and install Python dependencies
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application code to the container
COPY . .
# ... rest of dockerfile ...
while in requirements.txt this must be included:
gpiozero>=2.0.1
https://github.com/Gadgetoid/PY_LGPIO/releases/download/0.2.2.0/lgpio-0.2.2.0.tar.gz
no gpiod, rpi.gpiod, libgpiod or something else needed. Juste these two. you must run your python code as root. of course you could install these two packets also in Dockerfile with RUN. But this is probably the better way to go.
I hope this will help somebody.
While being happy that the package got installed and creating this post, I got another issue, that I get error when using gpiozero in python code:
this is my dockerfile:
the code runs fine on Raspberry Pi 5 root, but if running docker container with priviliged mode, it doesnt seem to work. Any Ideas, whats wrong?
_Originally posted by @Ed1ks in https://github.com/Gadgetoid/PY_LGPIO/issues/2#issuecomment-2129600938_