face This error file building docker image dlib

Viewed 1895

ERROR: Command errored out with exit status 1: command: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-oho_tlt5/dlib/setup.py'"'"'; file='"'"'/tmp/pip-install-oho_tlt5/dlib/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-vktrpqpq cwd: /tmp/pip-install-oho_tlt5/dlib/ Complete output (53 lines): running bdist_wheel 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 "/tmp/pip-install-oho_tlt5/dlib/setup.py", line 120, in get_cmake_version out = subprocess.check_output(['cmake', '--version']) File "/usr/local/lib/python3.8/subprocess.py", line 411, in check_output return run(*popenargs, stdout=PIPE, timeout=timeout, check=True, File "/usr/local/lib/python3.8/subprocess.py", line 489, in run with Popen(*popenargs, **kwargs) as process: File "/usr/local/lib/python3.8/subprocess.py", line 854, in init self._execute_child(args, executable, preexec_fn, close_fds, File "/usr/local/lib/python3.8/subprocess.py", line 1702, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'cmake'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "", line 1, in File "/tmp/pip-install-oho_tlt5/dlib/setup.py", line 223, in setup( File "/usr/local/lib/python3.8/site-packages/setuptools/init.py", line 144, in setup return distutils.core.setup(attrs) File "/usr/local/lib/python3.8/distutils/core.py", line 148, in setup dist.run_commands() File "/usr/local/lib/python3.8/distutils/dist.py", line 966, in run_commands self.run_command(cmd) File "/usr/local/lib/python3.8/distutils/dist.py", line 985, in run_command cmd_obj.run() File "/usr/local/lib/python3.8/site-packages/wheel/bdist_wheel.py", line 223, in run self.run_command('build') File "/usr/local/lib/python3.8/distutils/cmd.py", line 313, in run_command self.distribution.run_command(command) File "/usr/local/lib/python3.8/distutils/dist.py", line 985, in run_command cmd_obj.run() File "/usr/local/lib/python3.8/distutils/command/build.py", line 135, in run self.run_command(cmd_name) File "/usr/local/lib/python3.8/distutils/cmd.py", line 313, in run_command self.distribution.run_command(command) File "/usr/local/lib/python3.8/distutils/dist.py", line 985, in run_command cmd_obj.run() File "/tmp/pip-install-oho_tlt5/dlib/setup.py", line 129, in run cmake_version = self.get_cmake_version() File "/tmp/pip-install-oho_tlt5/dlib/setup.py", line 122, in get_cmake_version raise RuntimeError("\n*****************************************************************\n" + RuntimeError: ******************************************************************* CMake must be installed to build the following extensions: dlib *******************************************************************


ERROR: Failed building wheel for dlib


DOCKERFILE

FROM python:3

WORKDIR ./app

COPY ./requirements.txt .

RUN pip install --upgrade pip \
        && apt-get install -y --fix-missing\
        && pip install --no-cache-dir -r requirements.txt

COPY . ./app

ENTRYPOINT [ "python", "./app.py" ]
2 Answers

In your Dockerfile.

FROM python:3
WORKDIR ./app
COPY ./requirements.txt .
RUN pip install -U pip wheel cmake
RUN pip install -r requirements.txt
COPY . ./app
ENTRYPOINT [ "python", "./app.py" ]

first install cmake and wheel with pip, the packages you install from the requirement.txt file are first downloaded and then installed, for this reason it fails to install dlib.

In your requirements.txt put CMake as first

Related