pythondockernumpyscikit-learnraspbian

Dockerfile to install scikit-learn on rasp pi hardware


How to make a Dockerfile for Raspbian hardware that can install scikit-learn? I haven't had any luck with debian-slim or Alpine Linux images.

# Use a base image for Raspberry Pi with Alpine Linux
FROM arm32v6/alpine:3.14

# Update package repositories and install necessary dependencies
RUN apk --no-cache update && \
    apk --no-cache add python3 python3-dev py3-pip build-base gcc gfortran wget freetype-dev libpng-dev openblas-dev && \
    ln -s /usr/include/locale.h /usr/include/xlocale.h

# Install scikit-learn and bacpypes3 using pip3
RUN pip3 install scikit-learn bacpypes3

# Clean up by removing unnecessary packages and cache
RUN apk del python3-dev py3-pip build-base gcc gfortran && \
    rm -rf /var/cache/apk/*

# Set the working directory
WORKDIR /app

# Start your application
CMD ["python3", "bacnet_server.py"]

Solution

  • You can use APK to install scikit-learn

    From the documentation

    apk add py3-scikit-learn

    Installs the python3 package.