Unable to install dlib from Dockerfile on Raspberry Pi - docker

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 Downloading
http://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
What am I missing?

I was able to get it to work by changing the base image to
FROM raspbian/stretch
# get base image
FROM raspbian/stretch
RUN apt-get -y update
RUN apt-get install -y --fix-missing \
build-essential \
cmake \
libopenblas-dev \
libblas-dev \
liblapack-dev \
libatlas-base-dev \
libx11-dev \
libgtk-3-dev \
gfortran \
git \
wget \
curl \
graphicsmagick \
libgraphicsmagick1-dev \
libavcodec-dev \
libavformat-dev \
libboost-all-dev \
libgtk2.0-dev \
libjpeg-dev \
liblapack-dev \
libswscale-dev \
pkg-config \
python3-dev \
python3-numpy \
python3-pip \
software-properties-common \
zip \
&& apt-get clean && rm -rf /tmp/* /var/tmp/*
RUN pip3 install setuptools --upgrade
RUN pip3 install cython --upgrade
#Install dlib
RUN cd ~ && \
mkdir -p dlib && \
git clone -b 'v19.9' --single-branch https://github.com/davisking/dlib.git dlib/ && \
cd dlib/ && \
python3 setup.py install --yes

Related

KivyMd crashing on android

My workflow:
In google colab:
!pip install buildozer
!pip install cython==0.29.19
!sudo apt-get install -y \
python3-pip \
build-essential \
git \
python3 \
python3-dev \
ffmpeg \
libsdl2-dev \
libsdl2-image-dev \
libsdl2-mixer-dev \
libsdl2-ttf-dev \
libportmidi-dev \
libswscale-dev \
libavformat-dev \
libavcodec-dev \
zlib1g-dev
!sudo apt-get install -y \
libgstreamer1.0 \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good
!sudo apt-get install build-essential libsqlite3-dev sqlite3 bzip2 libbz2-dev zlib1g-dev libssl-dev openssl libgdbm-dev libgdbm-compat-dev liblzma-dev libreadline-dev libncursesw5-dev libffi-dev uuid-dev libffi6
!sudo apt-get install libffi-dev
!buildozer init
Edit the buildozer.spec file and change the lines:
requirements=python3,kivy==2.0.0,pillow,kivymd,requests,schedule,urllib3,charset_normalizer,idna
android.api = 32
Run:
!buildozer -v android debug
Deploy and run.
Result:
I/python: Traceback (most recent call last):
I/python: File "/content/.buildozer/android/app/main.py", line 4, in <module>
I/python: File "/content/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/myapp/arm64-v8a/kivymd/__init__.py", line 63, in <module>
I/python: File "/content/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/myapp/arm64-v8a/kivymd/font_definitions.py", line 10, in <module>
I/python: File "/content/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/myapp/arm64-v8a/kivy/core/text/__init__.py", line 85, in <module>
I/python: File "/content/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/myapp/arm64-v8a/kivy/graphics/__init__.py", line 89, in <module>
I/python: ModuleNotFoundError: No module named 'kivy.graphics.instructions'
How can I resolve this?
Thank you
SOLVED!
sudo apt update
sudo apt install -y git zip unzip openjdk-17-jdk python3-pip autoconf libtool pkg-config zlib1g-dev libncurses5-dev libncursesw5-dev libtinfo5 cmake libffi-dev libssl-dev
pip3 install --upgrade Cython==0.29.19
pip3 install --upgrade buildozer
buildozer init
Edit the buildozer.spec file and change the lines:
requirements = python3,kivy==2.1.0,kivymd==1.0.2,sdl2_ttf==2.0.15,pillow, # more packages ...
android.api = 33
Finally:
buildozer -v android debug

Installation pyproj does not work returned 127

I want to install pyproj on Debian on Docker.
This is my script:
FROM debian:latest
RUN /bin/bash -c 'apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq apt-utils && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq \
libpython3-dev \
python3-pip \
proj-bin \
curl \
libcurl4-gnutls-dev \
wget \
sqlite3 \
node-sqlite3 \
libsqlite3-dev \
libtiff5 \
libtiff5-dev \
make \
python-rtree && \
apt-get upgrade -yq && \
apt-get clean && \
apt-get update \
'
RUN wget https://download.osgeo.org/proj/proj-7.2.0.tar.gz
RUN tar -xvzf proj-7.2.0.tar.gz
RUN cd proj-7.2.0/ && ./configure && make && make install
RUN find / -name proj
RUN /bin/bash -c 'rm -rf /var/lib/apt/lists/* && \
pip3 install \
pyproj --no-binary pyproj \
'
This is the output:
Step 6/7 : RUN find / -name proj
---> Running in 6ae2ce5a5157
/usr/share/proj
/usr/local/share/proj
/usr/local/include/proj
/usr/local/bin/proj
/usr/bin/proj
/proj-7.2.0/src/.libs/proj
/proj-7.2.0/src/proj
/proj-7.2.0/include/proj
Removing intermediate container 6ae2ce5a5157
---> 9e652a740f23
Step 7/7 : RUN /bin/bash -c 'rm -rf /var/lib/apt/lists/* && pip3 install pyproj --no-binary pyproj '
---> Running in 2fa15199039b
Collecting pyproj
Downloading https://files.pythonhosted.org/packages/17/e5/3f5cdff3e955bcd768cdb0f4236f2d6e022aaa72f57caf7f4d5f552c88fc/pyproj-3.0.0.post1.tar.gz (663kB)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-r4rvjbmz/pyproj/setup.py", line 224, in <module>
ext_modules=get_extension_modules(),
File "/tmp/pip-install-r4rvjbmz/pyproj/setup.py", line 155, in get_extension_modules
proj_version = get_proj_version(proj_dir)
File "/tmp/pip-install-r4rvjbmz/pyproj/setup.py", line 22, in get_proj_version
proj_ver = subprocess.check_output(str(proj), stderr=subprocess.STDOUT).decode(
File "/usr/lib/python3.7/subprocess.py", line 395, in check_output
**kwargs).stdout
File "/usr/lib/python3.7/subprocess.py", line 487, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '/usr/local/bin/proj' returned non-zero exit status 127.
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-r4rvjbmz/pyproj/
Earlier I tried installing pyproj just via pip, it will install PROJ as a dependency, but with the wrong version. That's why I switched to the installation of the binaries via wget.
Also, I gave a find output to show that proj is actually in the right location.
Any suggestions?
https://pyproj4.github.io/pyproj/stable/installation.html
I would recommend either:
Upgrade to pip>=19 so PROJ 7.2 is in the wheel.
ENV PROJ_DIR=/path/to/proj/install and when you install PROJ: ./configure --prefix $PROJ_DIR

cant' build docker file for my service because of pip-req file not found error

i have created a Dockerfile that creates virtual env, installs all libs and activates that virtual env for further use.
the dockerfile:
FROM debian:9.4-slim
##################################################
# Install Anaconda 3:
##################################################
RUN apt-get update && apt-get install -y \
--fix-missing \
build-essential \
cmake \
gfortran \
git \
wget \
curl \
graphicsmagick \
libgraphicsmagick1-dev \
libatlas-dev \
libavcodec-dev \
libavformat-dev \
libgtk2.0-dev \
libjpeg-dev \
liblapack-dev \
libswscale-dev \
pkg-config \
python3-dev \
python3-numpy \
software-properties-common \
zip \
&& apt-get clean && rm -rf /tmp/* /var/tmp/* \
&& curl -o miniconda_install.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
&& bash miniconda_install.sh -b -p ~/anaconda3 \
&& echo 'export PATH="~/anaconda3/bin:$PATH"' >> ~/.bashrc \
&& ~/anaconda3/bin/conda update -n base conda \
&& rm miniconda_install.sh \
&& rm -rf /var/lib/apt/lists/* \
&& /bin/bash -c "source ~/.bashrc"
ENV PATH="~/anaconda3/bin:${PATH}"
##################################################
# Setup env for current project:
##################################################
EXPOSE 1487 1488
RUN /bin/bash -c "conda create -y -n voice"
ADD erjan_environment_var_for_voice.txt /tmp/setup/requirements.txt
RUN /bin/bash -c "source activate voice"
RUN /bin/bash -c "pip install -r /tmp/setup/requirements.txt"
WORKDIR /Service
ADD Service /Service
ENTRYPOINT ["/bin/bash", "-c", "source activate voice && ./run.sh"]
when running this command:
sudo docker build . -t jysan_bank:dev
the error:
ERROR: Command errored out with exit status 1:
command: /root/anaconda3/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-1mbm1qnz/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-1mbm1qnz/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-req-build-1mbm1qnz/pip-egg-info
cwd: /tmp/pip-req-build-1mbm1qnz/
Complete output (5 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/root/anaconda3/lib/python3.7/tokenize.py", line 447, in open
buffer = _builtin_open(filename, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-req-build-1mbm1qnz/setup.py'
I got this dockerfile from a similar project, it runs ok. I changed the requirements.txt file to include libs i needed.
why does it not work and asking for some file tmp/pip-req?

Docker: Failed building wheel for scipy

I'm trying for facerecogition from (https://github.com/jamct/facerec) on my raspberry pi 3. Therefore the by runs with the newest version of Raspbian Stretch.
I am running:
docker build -t facerec:latest .
But I get the following error:
ERROR: Failed building wheel for scipy
ERROR: Could not build wheels for scipy which use PEP 517 and cannot be installed directly
Here is a little bit more of the log:
creating build/temp.linux-armv7l-3.6/scipy/fft
creating build/temp.linux-armv7l-3.6/scipy/fft/_pocketfft
compile options: '-DPOCKETFFT_PTHREADS -I/root/.local/include/python3.6m -I/usr/local/include/python3.6m -I/tmp/pip-build-env-u7r4c8tr/overlay/lib/python3.6/site-packages/numpy/core/include -I/usr/local/include/python3.6m -c'
extra options: '-std=c++14 -fvisibility=hidden'
g++: scipy/fft/_pocketfft/pypocketfft.cxx
Running from scipy source directory.
/tmp/pip-build-env-u7r4c8tr/overlay/lib/python3.6/site-packages/numpy/distutils/system_info.py:572: UserWarning:
Atlas (http://math-atlas.sourceforge.net/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [atlas]) or by setting
the ATLAS environment variable.
self.calc_info()
/tmp/pip-build-env-u7r4c8tr/overlay/lib/python3.6/site-packages/numpy/distutils/system_info.py:664: UserWarning: Specified path /usr/include/python3.6m is invalid.
return self.get_paths(self.section, key)
scipy/fft/_pocketfft/pypocketfft.cxx:15:31: fatal error: pybind11/pybind11.h: No such file or directory
#include <pybind11/pybind11.h>
^
compilation terminated.
scipy/fft/_pocketfft/pypocketfft.cxx:15:31: fatal error: pybind11/pybind11.h: No such file or directory
#include <pybind11/pybind11.h>
^
compilation terminated.
error: Command "g++ -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPOCKETFFT_PTHREADS -I/root/.local/include/python3.6m -I/usr/local/include/python3.6m -I/tmp/pip-build-env-u7r4c8tr/overlay/lib/python3.6/site-packages/numpy/core/include -I/usr/local/include/python3.6m -c scipy/fft/_pocketfft/pypocketfft.cxx -o build/temp.linux-armv7l-3.6/scipy/fft/_pocketfft/pypocketfft.o -MMD -MF build/temp.linux-armv7l-3.6/scipy/fft/_pocketfft/pypocketfft.o.d -std=c++14 -fvisibility=hidden" failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for scipy
ERROR: Could not build wheels for scipy which use PEP 517 and cannot be installed directly
The command '/bin/sh -c cd /face_recognition && pip3 install -r requirements.txt && python3 setup.py install' returned a non-zero code: 1
This is the dockerfile:
#Dockerfile for face-recognition
#Based on https://github.com/denverdino/face_recognition_pi
FROM resin/raspberry-pi-python:3
COPY pip.conf /root/.pip/pip.conf
RUN apt-get -y update
RUN apt-get install -y --fix-missing \
build-essential \
cmake \
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 && pip3 install --upgrade picamera[array] dlib
RUN pip install --upgrade pip
RUN pip install --upgrade pip setuptools wheel
RUN git clone --single-branch https://github.com/ageitgey/face_recognition.git
RUN cd /face_recognition && \
pip3 install -r requirements.txt && \
python3 setup.py install
CMD cd /face_recognition/examples && \
python3 recognize_faces_in_pictures.py
Would be happy if somebody has an idea what to do now.
Thanks!
You have to install Pybind11 before building SciPy:
python3 -m pip install pybind11

the command ... returned a non-zero code 100 docker

I'm trying to install OpenVino on my Raspberry using Docker.
I have this Dockerfile:
FROM raspbian/stretch
ARG INSTALL_DIR="/opt/intel/inference_engine_vpu_arm"
RUN apt-get -y update \
&& DEBIAN_FRONTEND=noninteractive && apt-get -y upgrade && apt-get autoremove && \
apt-get install -y \
apt-transport-https \
build-essential \
cmake \
cpio \
lsb-release \
pciutils \
python3.5 \
python3.5-dev \
python3-pip \
python3-setuptools \
ffmpeg \
libjpeg-dev \
libtiff5-dev \
libjasper-dev \
libpng12-dev \
libavcodec-dev \
libavformat-dev \
libswscale-dev \
libv4l-dev \
libxvidcore-dev \
libx264-dev \
libgtk2.0-dev \
libgtk-3-dev \
libatlas-base-dev \
gfortran \
libgstreamer1.0-0 \
libgstreamer-plugins-base1.0-0
RUN usermod -a -G users "$(whoami)"
COPY inference_engine_vpu_arm $INSTALL_DIR
RUN sed -i "s|<INSTALLDIR>|$INSTALL_DIR|" $INSTALL_DIR/bin/setupvars.sh && \
echo "source $INSTALL_DIR/bin/setupvars.sh" >> $HOME/.bashrc
RUN ["/bin/bash", "-c", "source $INSTALL_DIR/bin/setupvars.sh && /bin/bash $INSTALL_DIR/install_dependencies/install_NCS_udev_rules.sh"]
RUN pip3 install numpy
RUN apt autoremove -y && \
rm -rf /var/lib/apt/lists/*
CMD ["/bin/bash"]
But I have this error when I try to build:
E: Unable to correct problems, you have held broken packages.
The command '/bin/sh -c apt-get -y update..... returned a non-zero code: 100
Do you have any idea?
Thanks
After a some google search it seems the error happens because the apt daemon is not able to connect to the configured repositories. This is likely since the base image was not updated for a while as i can see on docker hub.
If you not familiar with the available repositories you can generate them easily with online tools such as: https://debgen.simplylinux.ch/index.php?generate
You can put them into the docker image with a simple COPY command like
COPY sources.list /etc/apt/sources.list
where the first argument refers to a local file, the second to the docker image

Resources