Docker Community Forums

Share and learn in the Docker community.

Unable to install dlib from Dockerfile on Raspberry Pi

I asked this question on Stackoverflow, but no answers yet. https://stackoverflow.com/questions/57748375/unable-to-install-dlib-from-dockerfile-on-raspberry-pi

I’m trying to install dlib in Dockerfile on a Raspberry Pi 4.

Outside of Docker, I am able to install dlib on the Pi by running

pip3 install --upgrade dlib

But when I try to do it in a Dockerfile as follows:

FROM resin/raspberry-pi-python:3
COPY raspi.list /etc/apt/sources.list.d/raspi.list
COPY sources.list /etc/apt/sources.list
COPY pip.conf /root/.pip/pip.conf 
RUN apt-get -y update
RUN apt-get install -y --fix-missing \
    build-essential \
    cmake \
    libopenblas-dev \
    liblapack-dev \
    libatlas-base-dev \
    libx11-dev \
    libgtk-3-dev \
    gfortran \
    git \
    wget \
    curl \
    graphicsmagick \
    libgraphicsmagick1-dev \
    libatlas-dev \
    libavcodec-dev \
    libavformat-dev \
    libboost-all-dev \
    libgtk2.0-dev \
    libjpeg-dev \
    liblapack-dev \
    libswscale-dev \
    pkg-config \
    python3-dev \
    zip \
    && apt-get clean && rm -rf /tmp/* /var/tmp/*
RUN python3 -m ensurepip --upgrade

RUN pip3 install --upgrade dlib

I get errors when I try to build the docker image:

Step 9/12 : RUN pip3 install --upgrade dlib —> Running in bf5fa67b254d Looking in indexes:http://mirrors.aliyun.com/pypi/simple/ Collecting dlib Downloadinghttp://mirrors.aliyun.com/pypi/packages/05/57/e8a8caa3c89a27f80bc78da39c423e2553f482a3705adc619176a3a24b36/dlib-19.17.0.tar.gz (3.4MB) Installing collected packages: dlib Running setup.py install for dlib: started Running setup.py install for dlib: finished with status ‘error’ Complete output from command /usr/local/bin/python3.6 -u -c “import setuptools, tokenize; file =’/tmp/pip-install-sak074zk/dlib/setup.py’;f=getattr(tokenize, ‘open’, open)( file );code=f.read().replace(’\r\n’, ‘\n’);f.close();exec(compile(code, file , ‘exec’))” install --record /tmp/pip-record-7yn41l3u/install-record.txt --single-version-externally-managed --compile: running install running build running build_py package init file ‘dlib/ init .py’ not found (or not a regular file) running build_ext Traceback (most recent call last): File “”, line 1, in File “/tmp/pip-install-sak074zk/dlib/setup.py”, line 261, in ‘Topic :: Software Development’, File “/usr/local/lib/python3.6/site-packages/setuptools/ init .py”, line 129, in setup return distutils.core.setup(**attrs) File “/usr/local/lib/python3.6/distutils/core.py”, line 148, in setup dist.run_commands() File “/usr/local/lib/python3.6/distutils/dist.py”, line 955, in run_commands self.run_command(cmd) File “/usr/local/lib/python3.6/distutils/dist.py”, line 974, in run_command cmd_obj.run() File “/usr/local/lib/python3.6/site-packages/setuptools/command/install.py”, line 61, in run return orig.install.run(self) File “/usr/local/lib/python3.6/distutils/command/install.py”, line 545, in run self.run_command(‘build’) File “/usr/local/lib/python3.6/distutils/cmd.py”, line 313, in run_command self.distribution.run_command(command) File “/usr/local/lib/python3.6/distutils/dist.py”, line 974, in run_command cmd_obj.run() File “/usr/local/lib/python3.6/distutils/command/build.py”, line 135, in run self.run_command(cmd_name) File “/usr/local/lib/python3.6/distutils/cmd.py”, line 313, in run_command self.distribution.run_command(command) File “/usr/local/lib/python3.6/distutils/dist.py”, line 974, in run_command cmd_obj.run() File “/tmp/pip-install-sak074zk/dlib/setup.py”, line 129, in run cmake_version = self.get_cmake_version() File “/tmp/pip-install-sak074zk/dlib/setup.py”, line 120, in get_cmake_version out = subprocess.check_output([‘cmake’, ‘–version’]) File “/usr/local/lib/python3.6/subprocess.py”, line 336, in check_output **kwargs).stdout File “/usr/local/lib/python3.6/subprocess.py”, line 418, in run output=stdout, stderr=stderr) subprocess.CalledProcessError: Command ‘[‘cmake’, ‘–version’]’ died with .

Command “/usr/local/bin/python3.6 -u -c “import setuptools, tokenize; file =’/tmp/pip-install-sak074zk/dlib/setup.py’;f=getattr(tokenize, ‘open’, open)( file );code=f.read().replace(’\r\n’, ‘\n’);f.close();exec(compile(code, file , ‘exec’))” install --record /tmp/pip-record-7yn41l3u/install-record.txt --single-version-externally-managed --compile” failed with error code 1 in /tmp/pip-install-sak074zk/dlib/ You are using pip version 10.0.1, however version 19.2.3 is available. You should consider upgrading via the ‘pip install --upgrade pip’ command. The command ‘/bin/sh -c pip3 install --upgrade dlib’ returned a non-zero code: 1