Skip to content

Instantly share code, notes, and snippets.

@smitshilu
Last active June 19, 2024 10:00
Show Gist options
  • Save smitshilu/7b21016c496e412a966a34045a8c21ff to your computer and use it in GitHub Desktop.
Save smitshilu/7b21016c496e412a966a34045a8c21ff to your computer and use it in GitHub Desktop.
How to install dlib v19.9 or newer (w/ python bindings) from github on macOS and Ubuntu

How to install dlib v19.9 or newer (w/ python bindings) from github on macOS and Ubuntu

Pre-reqs:

  • Have Python 3 installed. On macOS, this could be installed from homebrew or even via standard Python 3.6 downloaded installer from https://www.python.org/download. On Linux, just use your package manager.
  • On macOS:
    • Install XCode from the Mac App Store (or install the XCode command line utils).
    • Have homebrew installed
  • On Linux:
    • For a full list of apt packages required, check out the example Dockerfile and copy what's installed there.
    • These instructions assume you are using Ubuntu 16.04 or newer. If you are using 14.04, you can try these installation instructions instead to work around the old CMake version.
  • These instructions assume you don't have an nVidia GPU and don't have Cuda and cuDNN installed and don't want GPU acceleration.

Clone the code from github:

git clone https://github.com/davisking/dlib.git

Build the main dlib library (optional if you just want to use Python):

cd dlib
mkdir build; cd build; cmake ..; cmake --build .

Build and install the Python extensions:

cd ..
python3 setup.py install

At this point, you should be able to run python3 and type import dlib successfully.


If you are looking for dlib with GPU support just check whether your cmake is finding CUDA or not?

You can check that while running cmake ... If you see following instruction then Dlib will use CUDA

-- Found CUDA: /usr/local/cuda (found suitable version "9.2", minimum required is "7.5") 
-- Looking for cuDNN install...
-- Found cuDNN: /usr/local/cuda/lib/libcudnn.dylib
-- Building a CUDA test project to see if your compiler is compatible with CUDA...
-- Checking if you have the right version of cuDNN installed.
-- Enabling CUDA support for dlib.  DLIB WILL USE CUDA
@Samu1199s
Copy link

While running "python3 setup.py install", I am getting this error: @smitshilu

(env) xyzuser@xyzAZGENPOCAI-04:~/dlib$ python3 setup.py install
running install
/home/xyzuser/env/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
/home/xyzuser/env/lib/python3.10/site-packages/setuptools/command/easy_install.py:144: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
running bdist_egg
running egg_info
creating tools/python/dlib.egg-info
writing tools/python/dlib.egg-info/PKG-INFO
writing dependency_links to tools/python/dlib.egg-info/dependency_links.txt
writing top-level names to tools/python/dlib.egg-info/top_level.txt
writing manifest file 'tools/python/dlib.egg-info/SOURCES.txt'
reading manifest file 'tools/python/dlib.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching 'tools/python/build*'
no previously-included directories found matching 'dlib/cmake_utils/*/build*'
warning: no previously-included files matching '*.pyc' found anywhere in distribution
adding license file 'LICENSE.txt'
writing manifest file 'tools/python/dlib.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_ext
Building extension for Python 3.10.13 (main, Aug 25 2023, 13:20:03) [GCC 9.4.0]
Invoking CMake setup: 'cmake /home/xyzuser/dlib/tools/python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/home/xyzuser/dlib/build/lib.linux-x86_64-cpython-310 -DPYTHON_EXECUTABLE=/home/xyzuser/env/bin/python3 -DCMAKE_BUILD_TYPE=Release'
-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Deprecation Warning at /home/xyzuser/dlib/dlib/external/pybind11/CMakeLists.txt:8 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- pybind11 v2.10.0
CMake Warning (dev) at /home/xyzuser/dlib/dlib/external/pybind11/tools/FindPythonLibsNew.cmake:98 (find_package):
  Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules
  are removed.  Run "cmake --help-policy CMP0148" for policy details.  Use
  the cmake_policy command to set the policy and suppress this warning.

Call Stack (most recent call first):
  /home/xyzuser/dlib/dlib/external/pybind11/tools/pybind11Tools.cmake:50 (find_package)
  /home/xyzuser/dlib/dlib/external/pybind11/tools/pybind11Common.cmake:180 (include)
  /home/xyzuser/dlib/dlib/external/pybind11/CMakeLists.txt:200 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found PythonInterp: /home/xyzuser/env/bin/python3 (found suitable version "3.10.13", minimum required is "3.6")
-- Found PythonLibs: python3.10
-- Performing Test HAS_FLTO
-- Performing Test HAS_FLTO - Success
-- Using CMake version: 3.29.0
-- Compiling dlib version: 19.24.99
-- SSE4 instructions can be executed by the host processor.
-- AVX instructions can be executed by the host processor.
-- Enabling AVX instructions
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Found X11: /usr/include
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Found system copy of libpng: /usr/lib/x86_64-linux-gnu/libpng.so;/usr/lib/x86_64-linux-gnu/libz.so
-- Found system copy of libjpeg: /usr/lib/x86_64-linux-gnu/libjpeg.so
-- Searching for JPEG XL
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2")
-- Checking for modules 'libjxl;libjxl_cms;libjxl_threads'
--   No package 'libjxl' found
--   No package 'libjxl_cms' found
--   No package 'libjxl_threads' found
 *****************************************************************************
 *** No JPEG XL libraries found.                                           ***
 *** On Ubuntu 23.04 and newer you can install them by executing           ***
 ***    sudo apt install libjxl-dev                                        ***
 ***                                                                       ***
 *** Otherwise, you can find precompiled packages here:                    ***
 ***    https://github.com/libjxl/libjxl/releases                          ***
 *****************************************************************************
-- Searching for BLAS and LAPACK
-- Searching for BLAS and LAPACK
-- Checking for module 'cblas'
--   No package 'cblas' found
-- Checking for module 'lapack'
--   Found lapack, version 0.3.20+ds
-- Looking for cblas_ddot
-- Looking for cblas_ddot - not found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of void*
-- Check size of void* - done
-- Found OpenBLAS library
-- Looking for sgetrf_single
-- Looking for sgetrf_single - found
-- Using OpenBLAS's built in LAPACK
-- Looking for cblas_ddot
-- Looking for cblas_ddot - found
-- Looking for sgesv
-- Looking for sgesv - not found
-- Looking for sgesv_
-- Looking for sgesv_ - not found
CMake Warning (dev) at /home/xyzuser/dlib/dlib/CMakeLists.txt:652 (find_package):
  Policy CMP0146 is not set: The FindCUDA module is removed.  Run "cmake
  --help-policy CMP0146" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.

This warning is for project developers.  Use -Wno-dev to suppress it.

CUDA_TOOLKIT_ROOT_DIR not found or specified
-- Could NOT find CUDA (missing: CUDA_TOOLKIT_ROOT_DIR CUDA_NVCC_EXECUTABLE CUDA_INCLUDE_DIRS CUDA_CUDART_LIBRARY) (Required is at least version "7.5")
-- Found CUDA, but CMake was unable to find the cuBLAS libraries that should be part of every basic CUDA install. Your CUDA install is somehow broken or incomplete. Since cuBLAS is required for dlib to use CUDA we won't use CUDA.
-- DID NOT FIND CUDA
-- Disabling CUDA support for dlib.  DLIB WILL NOT USE CUDA
-- Searching for FFMPEG/LIBAV
-- Checking for modules 'libavdevice;libavfilter;libavformat;libavcodec;libswresample;libswscale;libavutil'
--   No package 'libavdevice' found
--   No package 'libavfilter' found
 *****************************************************************************
 *** No FFMPEG/LIBAV libraries found.                                      ***
 *** On Ubuntu you can install them by executing                           ***
 ***    sudo apt install libavdevice-dev libavfilter-dev libavformat-dev   ***
 ***    sudo apt install libavcodec-dev libswresample-dev libswscale-dev   ***
 ***    sudo apt install libavutil-dev                                     ***
 *****************************************************************************
-- Configuring done (3.4s)
-- Generating done (0.0s)
-- Build files have been written to: /home/xyzuser/dlib/build/temp.linux-x86_64-cpython-310
Invoking CMake build: 'cmake --build . --config Release -- -j16'
[  1%] Building CXX object dlib_build/CMakeFiles/dlib.dir/base64/base64_kernel_1.cpp.o
[  2%] Building CXX object dlib_build/CMakeFiles/dlib.dir/bigint/bigint_kernel_1.cpp.o
[  3%] Building CXX object dlib_build/CMakeFiles/dlib.dir/bigint/bigint_kernel_2.cpp.o
[  4%] Building CXX object dlib_build/CMakeFiles/dlib.dir/bit_stream/bit_stream_kernel_1.cpp.o
[  5%] Building CXX object dlib_build/CMakeFiles/dlib.dir/entropy_decoder/entropy_decoder_kernel_1.cpp.o
[  6%] Building CXX object dlib_build/CMakeFiles/dlib.dir/entropy_decoder/entropy_decoder_kernel_2.cpp.o
[  7%] Building CXX object dlib_build/CMakeFiles/dlib.dir/entropy_encoder/entropy_encoder_kernel_2.cpp.o
[  9%] Building CXX object dlib_build/CMakeFiles/dlib.dir/entropy_encoder/entropy_encoder_kernel_1.cpp.o
[ 10%] Building CXX object dlib_build/CMakeFiles/dlib.dir/md5/md5_kernel_1.cpp.o
[ 11%] Building CXX object dlib_build/CMakeFiles/dlib.dir/tokenizer/tokenizer_kernel_1.cpp.o
[ 12%] Building CXX object dlib_build/CMakeFiles/dlib.dir/unicode/unicode.cpp.o
[ 13%] Building CXX object dlib_build/CMakeFiles/dlib.dir/test_for_odr_violations.cpp.o
[ 14%] Building CXX object dlib_build/CMakeFiles/dlib.dir/sockets/sockets_kernel_1.cpp.o
[ 15%] Building CXX object dlib_build/CMakeFiles/dlib.dir/bsp/bsp.cpp.o
[ 18%] Building CXX object dlib_build/CMakeFiles/dlib.dir/dir_nav/dir_nav_kernel_1.cpp.o
[ 18%] Building CXX object dlib_build/CMakeFiles/dlib.dir/fft/fft.cpp.o
[ 19%] Building CXX object dlib_build/CMakeFiles/dlib.dir/dir_nav/dir_nav_kernel_2.cpp.o
[ 20%] Building CXX object dlib_build/CMakeFiles/dlib.dir/dir_nav/dir_nav_extensions.cpp.o
[ 21%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_widgets/fonts.cpp.o
[ 22%] Building CXX object dlib_build/CMakeFiles/dlib.dir/linker/linker_kernel_1.cpp.o
[ 23%] Building CXX object dlib_build/CMakeFiles/dlib.dir/logger/extra_logger_headers.cpp.o
[ 25%] Building CXX object dlib_build/CMakeFiles/dlib.dir/logger/logger_kernel_1.cpp.o
[ 26%] Building CXX object dlib_build/CMakeFiles/dlib.dir/logger/logger_config_file.cpp.o
[ 27%] Building CXX object dlib_build/CMakeFiles/dlib.dir/misc_api/misc_api_kernel_1.cpp.o
In file included from /usr/include/features.h:486,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:586,
                 from /usr/include/c++/11/iosfwd:38,
                 from /usr/include/c++/11/ios:38,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /home/xyzuser/dlib/dlib/unicode/../assert.h:7,
                 from /home/xyzuser/dlib/dlib/unicode/../uintn.h:7,
                 from /home/xyzuser/dlib/dlib/unicode/unicode.h:6,
                 from /home/xyzuser/dlib/dlib/unicode/unicode.cpp:5:
In function ‘size_t mbstowcs(wchar_t*, const char*, size_t)’,
    inlined from ‘const wstring dlib::convert_mbstring_to_wstring(const string& ’ at /home/xyzuser/dlib/dlib/unicode/unicode.cpp:100:22:
/usr/include/x86_64-linux-gnu/bits/stdlib.h:115:10: warning: ‘size_t __mbstowcs_chk(wchar_t*, const char*, size_t, size_t)’ specified size 18446744073709551600 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
  115 |   return __glibc_fortify_n (mbstowcs, __len, sizeof (wchar_t),
      |          ^~~~~~~~~~~~~~~~~
In file included from /usr/include/stdlib.h:1027,
                 from /usr/include/c++/11/cstdlib:75,
                 from /usr/include/c++/11/ext/string_conversions.h:41,
                 from /usr/include/c++/11/bits/basic_string.h:6608,
                 from /usr/include/c++/11/string:55,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /home/xyzuser/dlib/dlib/unicode/../assert.h:7,
                 from /home/xyzuser/dlib/dlib/unicode/../uintn.h:7,
                 from /home/xyzuser/dlib/dlib/unicode/unicode.h:6,
                 from /home/xyzuser/dlib/dlib/unicode/unicode.cpp:5:
/usr/include/x86_64-linux-gnu/bits/stdlib.h: In function ‘const wstring dlib::convert_mbstring_to_wstring(const string&)’:
/usr/include/x86_64-linux-gnu/bits/stdlib.h:95:15: note: in a call to function  size_t __mbstowcs_chk(wchar_t*, const char*, size_t, size_t)’ declared with attribute ‘access (write_only, 1, 3)’
   95 | extern size_t __mbstowcs_chk (wchar_t *__restrict __dst,
      |               ^~~~~~~~~~~~~~
[ 28%] Building CXX object dlib_build/CMakeFiles/dlib.dir/misc_api/misc_api_kernel_2.cpp.o
[ 29%] Building CXX object dlib_build/CMakeFiles/dlib.dir/sockets/sockets_extensions.cpp.o
[ 30%] Building CXX object dlib_build/CMakeFiles/dlib.dir/sockets/sockets_kernel_2.cpp.o
[ 31%] Building CXX object dlib_build/CMakeFiles/dlib.dir/sockstreambuf/sockstreambuf.cpp.o
[ 32%] Building CXX object dlib_build/CMakeFiles/dlib.dir/sockstreambuf/sockstreambuf_unbuffered.cpp.o
[ 34%] Building CXX object dlib_build/CMakeFiles/dlib.dir/server/server_kernel.cpp.o
[ 35%] Building CXX object dlib_build/CMakeFiles/dlib.dir/server/server_iostream.cpp.o
[ 36%] Building CXX object dlib_build/CMakeFiles/dlib.dir/server/server_http.cpp.o
[ 37%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/multithreaded_object_extension.cpp.o
[ 38%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/threaded_object_extension.cpp.o
[ 39%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/threads_kernel_1.cpp.o
[ 40%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/threads_kernel_2.cpp.o
[ 42%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/threads_kernel_shared.cpp.o
[ 43%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/thread_pool_extension.cpp.o
[ 44%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/async.cpp.o
[ 45%] Building CXX object dlib_build/CMakeFiles/dlib.dir/timer/timer.cpp.o
[ 46%] Building CXX object dlib_build/CMakeFiles/dlib.dir/stack_trace.cpp.o
[ 47%] Building CXX object dlib_build/CMakeFiles/dlib.dir/cuda/cpu_dlib.cpp.o
[ 48%] Building CXX object dlib_build/CMakeFiles/dlib.dir/cuda/tensor_tools.cpp.o
[ 50%] Building CXX object dlib_build/CMakeFiles/dlib.dir/data_io/image_dataset_metadata.cpp.o
[ 51%] Building CXX object dlib_build/CMakeFiles/dlib.dir/data_io/mnist.cpp.o
[ 52%] Building CXX object dlib_build/CMakeFiles/dlib.dir/data_io/cifar.cpp.o
[ 53%] Building CXX object dlib_build/CMakeFiles/dlib.dir/global_optimization/global_function_search.cpp.o
[ 54%] Building CXX object dlib_build/CMakeFiles/dlib.dir/filtering/kalman_filter.cpp.o
[ 55%] Building CXX object dlib_build/CMakeFiles/dlib.dir/svm/auto.cpp.o
[ 56%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_widgets/widgets.cpp.o
[ 57%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_widgets/drawable.cpp.o
[ 59%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_widgets/canvas_drawing.cpp.o
[ 60%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_widgets/style.cpp.o
[ 61%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_widgets/base_widgets.cpp.o
[ 62%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_core/gui_core_kernel_1.cpp.o
[ 63%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_core/gui_core_kernel_2.cpp.o
[ 64%] Building CXX object dlib_build/CMakeFiles/dlib.dir/image_loader/png_loader.cpp.o
[ 65%] Building CXX object dlib_build/CMakeFiles/dlib.dir/image_saver/save_png.cpp.o
[ 67%] Building CXX object dlib_build/CMakeFiles/dlib.dir/image_loader/jpeg_loader.cpp.o
[ 68%] Building CXX object dlib_build/CMakeFiles/dlib.dir/image_saver/save_jpeg.cpp.o
[ 69%] Linking CXX static library libdlib.a
[ 69%] Built target dlib
[ 70%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/dlib.cpp.o
[ 71%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/matrix.cpp.o
[ 72%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/vector.cpp.o
[ 75%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/svm_rank_trainer.cpp.o
[ 75%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/svm_c_trainer.cpp.o
[ 76%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/decision_functions.cpp.o
[ 77%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/other.cpp.o
[ 78%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/basic.cpp.o
[ 79%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/cca.cpp.o
In file included from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/attr.h:13,
                 from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/detail/class.h:12,
                 from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/pybind11.h:13,
                 from /home/xyzuser/dlib/dlib/../dlib/python/pybind_utils.h:6,
                 from /home/xyzuser/dlib/dlib/../dlib/python.h:6,
                 from /home/xyzuser/dlib/tools/python/src/opaque_types.h:6,
                 from /home/xyzuser/dlib/tools/python/src/dlib.cpp:4:
/home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/detail/common.h:212:10: fatal error: Python.h: No such file or directory
  212 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
In file included from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/attr.h:13,
                 from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/detail/class.h:12,
                 from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/pybind11.h:13,
                 from /home/xyzuser/dlib/dlib/../dlib/python/pybind_utils.h:6,
                 from /home/xyzuser/dlib/dlib/../dlib/python.h:6,
                 from /home/xyzuser/dlib/tools/python/src/opaque_types.h:6,
                 from /home/xyzuser/dlib/tools/python/src/matrix.cpp:4:
/home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/detail/common.h:212:10: fatal error: Python.h: No such file or directory
  212 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
In file included from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/attr.h:13,
                 from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/detail/class.h:12,
                 from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/pybind11.h:13,
                 from /home/xyzuser/dlib/dlib/../dlib/python/pybind_utils.h:6,
                 from /home/xyzuser/dlib/dlib/../dlib/python.h:6,
                 from /home/xyzuser/dlib/tools/python/src/opaque_types.h:6,
                 from /home/xyzuser/dlib/tools/python/src/svm_c_trainer.cpp:4:
/home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/detail/common.h:212:10: fatal error: Python.h: No such file or directory
  212 | #include <Python.h>
      |          ^~~~~~~~~~
In file included from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/attr.h:13,
                 from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/detail/class.h:12,
                 from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/pybind11.h:13,
                 from /home/xyzuser/dlib/dlib/../dlib/python/pybind_utils.h:6,
                 from /home/xyzuser/dlib/dlib/../dlib/python.h:6,
                 from /home/xyzuser/dlib/tools/python/src/opaque_types.h:6,
                 from /home/xyzuser/dlib/tools/python/src/vector.cpp:4:
/home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/detail/common.h:212:10: fatal error: Python.h: No such file or directory
  212 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
compilation terminated.
In file included from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/attr.h:13,
                 from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/detail/class.h:12,
                 from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/pybind11.h:13,
                 from /home/xyzuser/dlib/dlib/../dlib/python/pybind_utils.h:6,
                 from /home/xyzuser/dlib/dlib/../dlib/python.h:6,
                 from /home/xyzuser/dlib/tools/python/src/opaque_types.h:6,
                 from /home/xyzuser/dlib/tools/python/src/svm_rank_trainer.cpp: :
/home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/detail/common.h:212:10: fatal error: Python.h: No such file or directory
  212 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
In file included from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/attr.h:13,
                 from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/detail/class.h:12,
                 from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/pybind11.h:13,
                 from /home/xyzuser/dlib/dlib/../dlib/python/pybind_utils.h:6,
                 from /home/xyzuser/dlib/dlib/../dlib/python.h:6,
                 from /home/xyzuser/dlib/tools/python/src/opaque_types.h:6,
                 from /home/xyzuser/dlib/tools/python/src/decision_functions.cpp:4:
/home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/detail/common.h:212:10: fatal error: Python.h: No such file or directory
  212 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
In file included from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/attr.h:13,
                 from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/detail/class.h:12,
                 from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/pybind11.h:13,
                 from /home/xyzuser/dlib/dlib/../dlib/python/pybind_utils.h:6,
                 from /home/xyzuser/dlib/dlib/../dlib/python.h:6,
                 from /home/xyzuser/dlib/tools/python/src/basic.cpp:3:
/home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/detail/common.h:212:10: fatal error: Python.h: No such file or directory
  212 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
gmake[2]: *** [CMakeFiles/_dlib_pybind11.dir/build.make:104: CMakeFiles/_dlib_pybind11.dir/src/vector.cpp.o] Error 1
gmake[2]: *** Waiting for unfinished jobs....
In file included from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/attr.h:13,
                 from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/detail/class.h:12,
                 from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/pybind11.h:13,
                 from /home/xyzuser/dlib/dlib/../dlib/python/pybind_utils.h:6,
                 from /home/xyzuser/dlib/dlib/../dlib/python.h:6,
                 from /home/xyzuser/dlib/tools/python/src/opaque_types.h:6,
                 from /home/xyzuser/dlib/tools/python/src/cca.cpp:4:
/home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/detail/common.h:212:10: fatal error: Python.h: No such file or directory
  212 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
In file included from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/attr.h:13,
                 from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/detail/class.h:12,
                 from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/pybind11.h:13,
                 from /home/xyzuser/dlib/dlib/../dlib/python/pybind_utils.h:6,
                 from /home/xyzuser/dlib/dlib/../dlib/python.h:6,
                 from /home/xyzuser/dlib/tools/python/src/opaque_types.h:6,
                 from /home/xyzuser/dlib/tools/python/src/other.cpp:4:
/home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/detail/common.h:212:10: fatal error: Python.h: No such file or directory
  212 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
gmake[2]: *** [CMakeFiles/_dlib_pybind11.dir/build.make:118: CMakeFiles/_dlib_pybind11.dir/src/svm_c_trainer.cpp.o] Error 1
gmake[2]: *** [CMakeFiles/_dlib_pybind11.dir/build.make:146: CMakeFiles/_dlib_pybind11.dir/src/decision_functions.cpp.o] Error 1
gmake[2]: *** [CMakeFiles/_dlib_pybind11.dir/build.make:188: CMakeFiles/_dlib_pybind11.dir/src/cca.cpp.o] Error 1
gmake[2]: *** [CMakeFiles/_dlib_pybind11.dir/build.make:174: CMakeFiles/_dlib_pybind11.dir/src/basic.cpp.o] Error 1
gmake[2]: *** [CMakeFiles/_dlib_pybind11.dir/build.make:160: CMakeFiles/_dlib_pybind11.dir/src/other.cpp.o] Error 1
gmake[2]: *** [CMakeFiles/_dlib_pybind11.dir/build.make:132: CMakeFiles/_dlib_pybind11.dir/src/svm_rank_trainer.cpp.o] Error 1
gmake[2]: *** [CMakeFiles/_dlib_pybind11.dir/build.make:90: CMakeFiles/_dlib_pybind11.dir/src/matrix.cpp.o] Error 1
gmake[2]: *** [CMakeFiles/_dlib_pybind11.dir/build.make:76: CMakeFiles/_dlib_pybind11.dir/src/dlib.cpp.o] Error 1
[ 84%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/svm_struct.cpp.o
[ 87%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/image3.cpp.o
[ 87%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/sequence_segmenter.cpp.o
[ 87%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/image.cpp.o
[ 87%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/image2.cpp.o
[ 87%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/image4.cpp.o
[ 87%] Building CXX object CMakeFiles/_dlib_pybind11.dir/src/rectangles.cpp.o
In file included from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/attr.h:13,
                 from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/detail/class.h:12,
                 from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/pybind11.h:13,
                 from /home/xyzuser/dlib/dlib/../dlib/python/pybind_utils.h:6,
                 from /home/xyzuser/dlib/dlib/../dlib/python.h:6,
                 from /home/xyzuser/dlib/tools/python/src/opaque_types.h:6,
                 from /home/xyzuser/dlib/tools/python/src/image3.cpp:3:
/home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/detail/common.h:212:10: fatal error: Python.h: No such file or directory
  212 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
In file included from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/attr.h:13,
                 from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/detail/class.h:12,
                 from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/pybind11.h:13,
                 from /home/xyzuser/dlib/dlib/../dlib/python/pybind_utils.h:6,
                 from /home/xyzuser/dlib/dlib/../dlib/python.h:6,
                 from /home/xyzuser/dlib/tools/python/src/opaque_types.h:6,
                 from /home/xyzuser/dlib/tools/python/src/sequence_segmenter.cpp:4:
/home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/detail/common.h:212:10: fatal error: Python.h: No such file or directory
  212 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
In file included from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/attr.h:13,
                 from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/detail/class.h:12,
                 from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/pybind11.h:13,
                 from /home/xyzuser/dlib/dlib/../dlib/python/pybind_utils.h:6,
                 from /home/xyzuser/dlib/dlib/../dlib/python.h:6,
                 from /home/xyzuser/dlib/tools/python/src/opaque_types.h:6,
                 from /home/xyzuser/dlib/tools/python/src/svm_struct.cpp:4:
/home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/detail/common.h:212:10: fatal error: Python.h: No such file or directory
  212 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
In file included from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/attr.h:13,
                 from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/detail/class.h:12,
                 from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/pybind11.h:13,
                 from /home/xyzuser/dlib/dlib/../dlib/python/pybind_utils.h:6,
                 from /home/xyzuser/dlib/dlib/../dlib/python.h:6,
                 from /home/xyzuser/dlib/tools/python/src/opaque_types.h:6,
                 from /home/xyzuser/dlib/tools/python/src/image.cpp:3:
/home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/detail/common.h:212:10: fatal error: Python.h: No such file or directory
  212 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
In file included from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/attr.h:13,
                 from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/detail/class.h:12,
                 from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/pybind11.h:13,
                 from /home/xyzuser/dlib/dlib/../dlib/python/pybind_utils.h:6,
                 from /home/xyzuser/dlib/dlib/../dlib/python.h:6,
                 from /home/xyzuser/dlib/tools/python/src/opaque_types.h:6,
                 from /home/xyzuser/dlib/tools/python/src/image2.cpp:3:
/home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/detail/common.h:212:10: fatal error: Python.h: No such file or directory
  212 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
gmake[2]: *** [CMakeFiles/_dlib_pybind11.dir/build.make:258: CMakeFiles/_dlib_pybind11.dir/src/image3.cpp.o] Error 1
gmake[2]: *** [CMakeFiles/_dlib_pybind11.dir/build.make:202: CMakeFiles/_dlib_pybind11.dir/src/sequence_segmenter.cpp.o] Error 1
In file included from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/attr.h:13,
                 from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/detail/class.h:12,
                 from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/pybind11.h:13,
                 from /home/xyzuser/dlib/dlib/../dlib/python/pybind_utils.h:6,
                 from /home/xyzuser/dlib/dlib/../dlib/python.h:6,
                 from /home/xyzuser/dlib/tools/python/src/opaque_types.h:6,
                 from /home/xyzuser/dlib/tools/python/src/image4.cpp:3:
/home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/detail/common.h:212:10: fatal error: Python.h: No such file or directory
  212 | #include <Python.h>
      |          ^~~~~~~~~~
gmake[2]: *** [CMakeFiles/_dlib_pybind11.dir/build.make:230: CMakeFiles/_dlib_pybind11.dir/src/image.cpp.o] Error 1
compilation terminated.
In file included from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/attr.h:13,
                 from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/detail/class.h:12,
                 from /home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/pybind11.h:13,
                 from /home/xyzuser/dlib/dlib/../dlib/python/pybind_utils.h:6,
                 from /home/xyzuser/dlib/dlib/../dlib/python.h:6,
                 from /home/xyzuser/dlib/tools/python/src/rectangles.cpp:4:
/home/xyzuser/dlib/dlib/external/pybind11/include/pybind11/detail/common.h:212:10: fatal error: Python.h: No such file or directory
  212 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
gmake[2]: *** [CMakeFiles/_dlib_pybind11.dir/build.make:216: CMakeFiles/_dlib_pybind11.dir/src/svm_struct.cpp.o] Error 1
gmake[2]: *** [CMakeFiles/_dlib_pybind11.dir/build.make:244: CMakeFiles/_dlib_pybind11.dir/src/image2.cpp.o] Error 1
gmake[2]: *** [CMakeFiles/_dlib_pybind11.dir/build.make:272: CMakeFiles/_dlib_pybind11.dir/src/image4.cpp.o] Error 1
gmake[2]: *** [CMakeFiles/_dlib_pybind11.dir/build.make:286: CMakeFiles/_dlib_pybind11.dir/src/rectangles.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:118: CMakeFiles/_dlib_pybind11.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2
Traceback (most recent call last):
  File "/home/xyzuser/dlib/setup.py", line 220, in <module>
    setup(
  File "/home/xyzuser/env/lib/python3.10/site-packages/setuptools/__init__.py", line 87, in setup
    return distutils.core.setup(**attrs)
  File "/home/xyzuser/env/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 185, in setup
    return run_commands(dist)
  File "/home/xyzuser/env/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
    dist.run_commands()
  File "/home/xyzuser/env/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 968, in run_commands
    self.run_command(cmd)
  File "/home/xyzuser/env/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command
    super().run_command(command)
  File "/home/xyzuser/env/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
    cmd_obj.run()
  File "/home/xyzuser/env/lib/python3.10/site-packages/setuptools/command/install.py", line 74, in run
    self.do_egg_install()
  File "/home/xyzuser/env/lib/python3.10/site-packages/setuptools/command/install.py", line 123, in do_egg_install
    self.run_command('bdist_egg')
  File "/home/xyzuser/env/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 319, in run_command
    self.distribution.run_command(command)
  File "/home/xyzuser/env/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command
    super().run_command(command)
  File "/home/xyzuser/env/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
    cmd_obj.run()
  File "/home/xyzuser/env/lib/python3.10/site-packages/setuptools/command/bdist_egg.py", line 165, in run
    cmd = self.call_command('install_lib', warn_dir=0)
  File "/home/xyzuser/env/lib/python3.10/site-packages/setuptools/command/bdist_egg.py", line 151, in call_command
    self.run_command(cmdname)
  File "/home/xyzuser/env/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 319, in run_command
    self.distribution.run_command(command)
  File "/home/xyzuser/env/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command
    super().run_command(command)
  File "/home/xyzuser/env/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
    cmd_obj.run()
  File "/home/xyzuser/env/lib/python3.10/site-packages/setuptools/command/install_lib.py", line 11, in run
    self.build()
  File "/home/xyzuser/env/lib/python3.10/site-packages/setuptools/_distutils/command/install_lib.py", line 112, in build
    self.run_command('build_ext')
  File "/home/xyzuser/env/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 319, in run_command
    self.distribution.run_command(command)
  File "/home/xyzuser/env/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command
    super().run_command(command)
  File "/home/xyzuser/env/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
    cmd_obj.run()
  File "/home/xyzuser/dlib/setup.py", line 130, in run
    self.build_extension(ext)
  File "/home/xyzuser/dlib/setup.py", line 170, in build_extension
    subprocess.check_call(cmake_build, cwd=build_folder)
  File "/usr/lib/python3.10/subprocess.py", line 369, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--config', 'Release', '--', '-j16']' returned non-zero exit status 2.

i have the same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment