Skip to content

Instantly share code, notes, and snippets.

@ageitgey
Last active November 30, 2024 16:31
Show Gist options
  • Save ageitgey/629d75c1baac34dfa5ca2a1928a7aeaf to your computer and use it in GitHub Desktop.
Save ageitgey/629d75c1baac34dfa5ca2a1928a7aeaf 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

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 (since none of the current Mac models support this).

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.

@VlasovKirill
Copy link

VlasovKirill commented Dec 20, 2020

Hi, how do we cross compile python binding libs on new MAC M1 for x86_64 ? I tried following and still got arm64.

make
cmake -DCMAKE_OSX_ARCHITECTURES=x86_64 ..
cmake --build .
python3 setup.py install

find . -name "*.so" -exec file {} ;
./build/lib.macosx-10.9-x86_64-3.9/_dlib_pybind11.cpython-39-darwin.so: Mach-O 64-bit bundle arm64

How can I build python bindings which are for x86_64 ?

Probably I have the same problem with new MAC M1. No matter what I do, I get the same error.

 import dlib
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/dlib/__init__.py", line 19, in <module>
    from _dlib_pybind11 import *
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/_dlib_pybind11.cpython-39-darwin.so, 2): no suitable image found.  Did find:
	/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/_dlib_pybind11.cpython-39-darwin.so: mach-o, but wrong architecture
	/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/_dlib_pybind11.cpython-39-darwin.so: mach-o, but wrong architecture

@Amoscui
Copy link

Amoscui commented Nov 24, 2021

Hi, How can I use dlib to run on the MAC M1 ? I tried many methods, but they all got this error.

import dlib
ImportError: dlopen(/Users/xxxx/miniforge3/envs/py39/lib/python3.9/site-packages/_dlib_pybind11.cpython-39-darwin.so, 0x0002): tried: '/Users/xxxx/miniforge3/envs/py39/lib/python3.9/site-packages/_dlib_pybind11.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/_dlib_pybind11.cpython-39-darwin.so' (no such file), '/usr/lib/_dlib_pybind11.cpython-39-darwin.so' (no such file)

@Roman-Buckle
Copy link

Hi i am having an issue running the final command, it gets very close to installing and then i am met with this:

Installed /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/dlib-19.22.99-py3.10-macosx-10.9-universal2.egg
Processing dependencies for dlib==19.22.99
Searching for dlib==19.22.99
Reading https://pypi.org/simple/dlib/
No local packages or working download links found for dlib==19.22.99
error: Could not find suitable distribution for Requirement.parse('dlib==19.22.99')

If anyone knows how to solve this issue that would be great!

@chencang
Copy link

cmake -DCMAKE_CXX_COMPILER=/usr/bin/g++ -DCMAKE_C_COMPILER=/usr/bin/gcc ..

see:https://stackoverflow.com/questions/70524164/cmake-c-compiler-not-set-after-enablelanguage?noredirect=1&lq=1

@tsfanning21
Copy link

I am also receiving an error towards the end of the python3 setup: similar to above but a different version:

Installed /Library/Python/3.8/site-packages/dlib-19.24.99-py3.8-macosx-10.14-arm64.egg
Processing dependencies for dlib==19.24.99
Searching for dlib==19.24.99
Reading https://pypi.org/simple/dlib/
No local packages or working download links found for dlib==19.24.99
error: Could not find suitable distribution for Requirement.parse('dlib==19.24.99')

@JM-command
Copy link

2 warnings generated.
5 warnings generated.
1 warning generated.
12 warnings generated.
7 warnings generated.
4 warnings generated.

bruh...

@copbint
Copy link

copbint commented Jul 6, 2022

I am not familiar with pip, but this simple command work on ubuntu 20.04:

pip install dlib-binary

referenced from: https://pypi.org/project/dlib-binary/

then we can import dlib in python3:

root@copbint:~# python3
Python 3.8.10 (default, Mar 15 2022, 12:22:08)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dlib
>>>

@tcoln
Copy link

tcoln commented Aug 16, 2022

I am not familiar with pip, but this simple command work on ubuntu 20.04:

pip install dlib-binary

referenced from: https://pypi.org/project/dlib-binary/

then we can import dlib in python3:

root@copbint:~# python3
Python 3.8.10 (default, Mar 15 2022, 12:22:08)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dlib
>>>

Thanks, it does work!

@niktheo
Copy link

niktheo commented Sep 1, 2022

Does anyone has a solution to that?

File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/dlib/__init__.py", line 19, in <module> from _dlib_pybind11 import * ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/_dlib_pybind11.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace (_png_do_expand_palette_rgb8_neon)

@ltst-slk
Copy link

ltst-slk commented Sep 3, 2022

@niktheo

Does anyone has a solution to that?

File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/dlib/__init__.py", line 19, in <module> from _dlib_pybind11 import * ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/_dlib_pybind11.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace (_png_do_expand_palette_rgb8_neon)

I have same issue ,
but when I check on repository dlib.
I found some replay for mac m1.

Please uninstall your dlib . And do this Step.

  1. brew install cmake
  2. brew install dlib
  3. pip install dlib

@niktheo
Copy link

niktheo commented Sep 3, 2022

Im still facing the same issue?
Do you have any other ideas ?
Thanks

@KPB98115
Copy link

KPB98115 commented Dec 6, 2022

I have noticed there have some problem with dlib version 19.24.99, there is no 19.24.99 for dlib(only 19.24.0). Is there any comment of this issue?

`[100%] Built target _dlib_pybind11
creating build/bdist.macosx-10.9-universal2
creating build/bdist.macosx-10.9-universal2/egg
creating build/bdist.macosx-10.9-universal2/egg/dlib
copying build/lib.macosx-10.9-universal2-cpython-39/dlib/init.py -> build/bdist.macosx-10.9-universal2/egg/dlib
copying build/lib.macosx-10.9-universal2-cpython-39/_dlib_pybind11.cpython-39-darwin.so -> build/bdist.macosx-10.9-universal2/egg
byte-compiling build/bdist.macosx-10.9-universal2/egg/dlib/init.py to init.cpython-39.pyc
creating stub loader for _dlib_pybind11.cpython-39-darwin.so
byte-compiling build/bdist.macosx-10.9-universal2/egg/_dlib_pybind11.py to _dlib_pybind11.cpython-39.pyc
creating build/bdist.macosx-10.9-universal2/egg/EGG-INFO
copying tools/python/dlib.egg-info/PKG-INFO -> build/bdist.macosx-10.9-universal2/egg/EGG-INFO
copying tools/python/dlib.egg-info/SOURCES.txt -> build/bdist.macosx-10.9-universal2/egg/EGG-INFO
copying tools/python/dlib.egg-info/dependency_links.txt -> build/bdist.macosx-10.9-universal2/egg/EGG-INFO
copying tools/python/dlib.egg-info/not-zip-safe -> build/bdist.macosx-10.9-universal2/egg/EGG-INFO
copying tools/python/dlib.egg-info/top_level.txt -> build/bdist.macosx-10.9-universal2/egg/EGG-INFO
writing build/bdist.macosx-10.9-universal2/egg/EGG-INFO/native_libs.txt
creating dist
creating 'dist/dlib-19.24.99-py3.9-macosx-10.9-universal2.egg' and adding 'build/bdist.macosx-10.9-universal2/egg' to it
removing 'build/bdist.macosx-10.9-universal2/egg' (and everything under it)
Processing dlib-19.24.99-py3.9-macosx-10.9-universal2.egg
creating /Users/kingston/Doc/workplace/py_venv/lab_faceRec/lib/python3.9/site-packages/dlib-19.24.99-py3.9-macosx-10.9-universal2.egg
Extracting dlib-19.24.99-py3.9-macosx-10.9-universal2.egg to /Users/kingston/Doc/workplace/py_venv/lab_faceRec/lib/python3.9/site-packages
Adding dlib 19.24.99 to easy-install.pth file

Installed /Users/kingston/Doc/workplace/py_venv/lab_faceRec/lib/python3.9/site-packages/dlib-19.24.99-py3.9-macosx-10.9-universal2.egg
Processing dependencies for dlib==19.24.99
Searching for dlib==19.24.99
Reading https://pypi.org/simple/dlib/
/Users/kingston/Doc/workplace/py_venv/lab_faceRec/lib/python3.9/site-packages/pkg_resources/init.py:123: PkgResourcesDeprecationWarning: is an invalid version and will not be supported in a future release
warnings.warn(
No local packages or working download links found for dlib==19.24.99
error: Could not find suitable distribution for Requirement.parse('dlib==19.24.99')
`

@priyanshugoel001
Copy link

This is Easiest and best solution provided on internet

@DomenicoL
Copy link

I received an error on: python3 setup.py install

/home/domenico/dlib/setup.py:39: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
from distutils import log
Traceback (most recent call last):
File "/home/domenico/dlib/setup.py", line 39, in
from distutils import log
ImportError: cannot import name 'log' from 'distutils' (/usr/lib/python3.10/distutils/init.py)

Any Idea?

@liwg1995
Copy link

liwg1995 commented Apr 6, 2023 via email

@abedputra
Copy link

is anyone able to install dlib to a server running Centos 7?

@liwg1995
Copy link

liwg1995 commented Apr 29, 2023 via email

@RazzaqAsad
Copy link

dlib installing issue using vs code window 10/11 can you please guide

ERROR:
(myenv) F:\PYTHON\FaceRecognition>pip install face_recognition
Collecting face_recognition
Using cached face_recognition-1.3.0-py2.py3-none-any.whl (15 kB)
Collecting face-recognition-models>=0.3.0 (from face_recognition)
Using cached face_recognition_models-0.3.0-py2.py3-none-any.whl
Collecting Click>=6.0 (from face_recognition)
Using cached click-8.1.7-py3-none-any.whl (97 kB)
Collecting dlib>=19.7 (from face_recognition)
Using cached dlib-19.24.2.tar.gz (11.8 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: numpy in f:\python\facerecognition\myenv\lib\site-packages (from face_recognition) (1.25.2)
Collecting Pillow (from face_recognition)
Using cached Pillow-10.0.0-cp311-cp311-win_amd64.whl (2.5 MB)
Collecting colorama (from Click>=6.0->face_recognition)
Using cached colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Building wheels for collected packages: dlib
Building wheel for dlib (pyproject.toml) ... error
error: subprocess-exited-with-error

× Building wheel for dlib (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [78 lines of output]
running bdist_wheel
running build
running build_ext
:125: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
Building extension for Python 3.11.4 (tags/v3.11.4:d2340ef, Jun 7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)]
Invoking CMake setup: 'cmake C:\Users\asad4\AppData\Local\Temp\pip-install-yzj24ii4\dlib_9e9a5d63f31b40ac926778278f91eca0\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\asad4\AppData\Local\Temp\pip-install-yzj24ii4\dlib_9e9a5d63f31b40ac926778278f91eca0\build\lib.win-amd64-cpython-311 -DPYTHON_EXECUTABLE=F:\PYTHON\FaceRecognition\myenv\Scripts\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\asad4\AppData\Local\Temp\pip-install-yzj24ii4\dlib_9e9a5d63f31b40ac926778278f91eca0\build\lib.win-amd64-cpython-311 -A x64'
-- Building for: NMake Makefiles
CMake Error at CMakeLists.txt:5 (message):

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


    You must use Visual Studio to build a python extension on windows.  If you
    are getting this error it means you have not installed Visual C++.  Note
    that there are many flavors of Visual Studio, like Visual Studio for C#
    development.  You need to install Visual Studio for C++.


    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!




  -- Configuring incomplete, errors occurred!
  Traceback (most recent call last):
    File "F:\PYTHON\FaceRecognition\myenv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
      main()
    File "F:\PYTHON\FaceRecognition\myenv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "F:\PYTHON\FaceRecognition\myenv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 251, in build_wheel
      return _build_backend().build_wheel(wheel_directory, config_settings,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\asad4\AppData\Local\Temp\pip-build-env-2vmk3er9\overlay\Lib\site-packages\setuptools\build_meta.py", line 434, in build_wheel
      return self._build_with_temp_dir(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\asad4\AppData\Local\Temp\pip-build-env-2vmk3er9\overlay\Lib\site-packages\setuptools\build_meta.py", line 419, in _build_with_temp_dir
      self.run_setup()
    File "C:\Users\asad4\AppData\Local\Temp\pip-build-env-2vmk3er9\overlay\Lib\site-packages\setuptools\build_meta.py", line 341, in run_setup
      exec(code, locals())
    File "<string>", line 218, in <module>
    File "C:\Users\asad4\AppData\Local\Temp\pip-build-env-2vmk3er9\overlay\Lib\site-packages\setuptools\__init__.py", line 107, in setup
      return distutils.core.setup(**attrs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\asad4\AppData\Local\Temp\pip-build-env-2vmk3er9\overlay\Lib\site-packages\setuptools\_distutils\core.py", line 185, in setup
      return run_commands(dist)
             ^^^^^^^^^^^^^^^^^^
    File "C:\Users\asad4\AppData\Local\Temp\pip-build-env-2vmk3er9\overlay\Lib\site-packages\setuptools\_distutils\core.py", line 201, in run_commands
      dist.run_commands()
    File "C:\Users\asad4\AppData\Local\Temp\pip-build-env-2vmk3er9\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 969, in run_commands
      self.run_command(cmd)
    File "C:\Users\asad4\AppData\Local\Temp\pip-build-env-2vmk3er9\overlay\Lib\site-packages\setuptools\dist.py", line 1233, in run_command
      super().run_command(command)
    File "C:\Users\asad4\AppData\Local\Temp\pip-build-env-2vmk3er9\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command
      cmd_obj.run()
    File "C:\Users\asad4\AppData\Local\Temp\pip-build-env-2vmk3er9\overlay\Lib\site-packages\wheel\bdist_wheel.py", line 349, in run
      self.run_command("build")
    File "C:\Users\asad4\AppData\Local\Temp\pip-build-env-2vmk3er9\overlay\Lib\site-packages\setuptools\_distutils\cmd.py", line 318, in run_command
      self.distribution.run_command(command)
    File "C:\Users\asad4\AppData\Local\Temp\pip-build-env-2vmk3er9\overlay\Lib\site-packages\setuptools\dist.py", line 1233, in run_command
      super().run_command(command)
    File "C:\Users\asad4\AppData\Local\Temp\pip-build-env-2vmk3er9\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command
      cmd_obj.run()
    File "C:\Users\asad4\AppData\Local\Temp\pip-build-env-2vmk3er9\overlay\Lib\site-packages\setuptools\_distutils\command\build.py", line 131, in run
      self.run_command(cmd_name)
    File "C:\Users\asad4\AppData\Local\Temp\pip-build-env-2vmk3er9\overlay\Lib\site-packages\setuptools\_distutils\cmd.py", line 318, in run_command
      self.distribution.run_command(command)
    File "C:\Users\asad4\AppData\Local\Temp\pip-build-env-2vmk3er9\overlay\Lib\site-packages\setuptools\dist.py", line 1233, in run_command
      super().run_command(command)
    File "C:\Users\asad4\AppData\Local\Temp\pip-build-env-2vmk3er9\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command
      cmd_obj.run()
    File "<string>", line 130, in run
    File "<string>", line 167, in build_extension
    File "C:\Users\asad4\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 413, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\asad4\\AppData\\Local\\Temp\\pip-install-yzj24ii4\\dlib_9e9a5d63f31b40ac926778278f91eca0\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\asad4\\AppData\\Local\\Temp\\pip-install-yzj24ii4\\dlib_9e9a5d63f31b40ac926778278f91eca0\\build\\lib.win-amd64-cpython-311', '-DPYTHON_EXECUTABLE=F:\\PYTHON\\FaceRecognition\\myenv\\Scripts\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\asad4\\AppData\\Local\\Temp\\pip-install-yzj24ii4\\dlib_9e9a5d63f31b40ac926778278f91eca0\\build\\lib.win-amd64-cpython-311', '-A', 'x64']' returned non-zero exit status 1.
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for dlib
Failed to build dlib
ERROR: Could not build wheels for dlib, which is required to install pyproject.toml-based projects

@Cyb3r-0
Copy link

Cyb3r-0 commented Dec 24, 2023

dlib installing issue using Command prompt and vs code both in window 11 can you please guide

PS C:\Users\TARUN PAUL\Coding> pip install cmake
Collecting cmake
Using cached cmake-3.28.1-py2.py3-none-win_amd64.whl.metadata (6.5 kB)
Using cached cmake-3.28.1-py2.py3-none-win_amd64.whl (35.8 MB)
Installing collected packages: cmake
Successfully installed cmake-3.28.1
PS C:\Users\TARUN PAUL\Coding> pip install dlib
Collecting dlib
Using cached dlib-19.24.2.tar.gz (11.8 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: dlib
Building wheel for dlib (pyproject.toml) ... error
error: subprocess-exited-with-error

× Building wheel for dlib (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [78 lines of output]
running bdist_wheel
running build
running build_ext
:125: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
Building extension for Python 3.11.4 (tags/v3.11.4:d2340ef, Jun 7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)]
Invoking CMake setup: 'cmake C:\Users\TARUN PAUL\AppData\Local\Temp\pip-install-ao8p44qq\dlib_871dc5b39a78423394254e859b7bb660\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\TARUN PAUL\AppData\Local\Temp\pip-install-ao8p44qq\dlib_871dc5b39a78423394254e859b7bb660\build\lib.win-amd64-cpython-311 -DPYTHON_EXECUTABLE=C:\Users\TARUN PAUL\AppData\Local\Programs\Python\Python311\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\TARUN PAUL\AppData\Local\Temp\pip-install-ao8p44qq\dlib_871dc5b39a78423394254e859b7bb660\build\lib.win-amd64-cpython-311 -A x64'
-- Building for: NMake Makefiles
CMake Error at CMakeLists.txt:5 (message):

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


    You must use Visual Studio to build a python extension on windows.  If you
    are getting this error it means you have not installed Visual C++.  Note
    that there are many flavors of Visual Studio, like Visual Studio for C#
    development.  You need to install Visual Studio for C++.      


    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!




  -- Configuring incomplete, errors occurred!
  Traceback (most recent call last):
    File "C:\Users\TARUN PAUL\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
      main()
    File "C:\Users\TARUN PAUL\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])       
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^       
    File "C:\Users\TARUN PAUL\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 251, in build_wheel
      return _build_backend().build_wheel(wheel_directory, config_settings,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\TARUN PAUL\AppData\Local\Temp\pip-build-env-2a2d9owp\overlay\Lib\site-packages\setuptools\build_meta.py", line 404, in build_wheel
      return self._build_with_temp_dir(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\TARUN PAUL\AppData\Local\Temp\pip-build-env-2a2d9owp\overlay\Lib\site-packages\setuptools\build_meta.py", line 389, in _build_with_temp_dir
      self.run_setup()
    File "C:\Users\TARUN PAUL\AppData\Local\Temp\pip-build-env-2a2d9owp\overlay\Lib\site-packages\setuptools\build_meta.py", line 311, in run_setup
      exec(code, locals())
    File "<string>", line 218, in <module>
    File "C:\Users\TARUN PAUL\AppData\Local\Temp\pip-build-env-2a2d9owp\overlay\Lib\site-packages\setuptools\__init__.py", line 103, in setup
      return distutils.core.setup(**attrs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\TARUN PAUL\AppData\Local\Temp\pip-build-env-2a2d9owp\overlay\Lib\site-packages\setuptools\_distutils\core.py", line 185, in setup
      return run_commands(dist)
             ^^^^^^^^^^^^^^^^^^
    File "C:\Users\TARUN PAUL\AppData\Local\Temp\pip-build-env-2a2d9owp\overlay\Lib\site-packages\setuptools\_distutils\core.py", line 201, in run_commands
      dist.run_commands()
    File "C:\Users\TARUN PAUL\AppData\Local\Temp\pip-build-env-2a2d9owp\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 969, in run_commands
      self.run_command(cmd)
    File "C:\Users\TARUN PAUL\AppData\Local\Temp\pip-build-env-2a2d9owp\overlay\Lib\site-packages\setuptools\dist.py", line 963, in run_command
      super().run_command(command)
    File "C:\Users\TARUN PAUL\AppData\Local\Temp\pip-build-env-2a2d9owp\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command
      cmd_obj.run()
    File "C:\Users\TARUN PAUL\AppData\Local\Temp\pip-build-env-2a2d9owp\overlay\Lib\site-packages\wheel\bdist_wheel.py", line 368, in run
      self.run_command("build")
    File "C:\Users\TARUN PAUL\AppData\Local\Temp\pip-build-env-2a2d9owp\overlay\Lib\site-packages\setuptools\_distutils\cmd.py", line 318, in run_command
      self.distribution.run_command(command)
    File "C:\Users\TARUN PAUL\AppData\Local\Temp\pip-build-env-2a2d9owp\overlay\Lib\site-packages\setuptools\dist.py", line 963, in run_command
      super().run_command(command)
    File "C:\Users\TARUN PAUL\AppData\Local\Temp\pip-build-env-2a2d9owp\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command
      cmd_obj.run()
    File "C:\Users\TARUN PAUL\AppData\Local\Temp\pip-build-env-2a2d9owp\overlay\Lib\site-packages\setuptools\_distutils\command\build.py", line 131, in run
      self.run_command(cmd_name)
    File "C:\Users\TARUN PAUL\AppData\Local\Temp\pip-build-env-2a2d9owp\overlay\Lib\site-packages\setuptools\_distutils\cmd.py", line 318, in run_command
      self.distribution.run_command(command)
    File "C:\Users\TARUN PAUL\AppData\Local\Temp\pip-build-env-2a2d9owp\overlay\Lib\site-packages\setuptools\dist.py", line 963, in run_command
      super().run_command(command)
    File "C:\Users\TARUN PAUL\AppData\Local\Temp\pip-build-env-2a2d9owp\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command
      cmd_obj.run()
    File "<string>", line 130, in run
    File "<string>", line 167, in build_extension
    File "C:\Users\TARUN PAUL\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 413, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\TARUN PAUL\\AppData\\Local\\Temp\\pip-install-ao8p44qq\\dlib_871dc5b39a78423394254e859b7bb660\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\TARUN PAUL\\AppData\\Local\\Temp\\pip-install-ao8p44qq\\dlib_871dc5b39a78423394254e859b7bb660\\build\\lib.win-amd64-cpython-311', '-DPYTHON_EXECUTABLE=C:\\Users\\TARUN PAUL\\AppData\\Local\\Programs\\Python\\Python311\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\TARUN PAUL\\AppData\\Local\\Temp\\pip-install-ao8p44qq\\dlib_871dc5b39a78423394254e859b7bb660\\build\\lib.win-amd64-cpython-311', '-A', 'x64']' returned non-zero exit status 1.
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for dlib
Failed to build dlib
ERROR: Could not build wheels for dlib, which is required to install pyproject.toml-based projects

@liwg1995
Copy link

liwg1995 commented Dec 24, 2023 via email

@Cyb3r-0
Copy link

Cyb3r-0 commented Dec 25, 2023

好的。
一旦您得到我的问题相关模块的答案,请尽快回复我。

@shuvo881
Copy link

shuvo881 commented Aug 3, 2024

I got this error:

fatal error: Python.h: No such file or directory
274 | #include <Python.h>
| ^~~~~~~~~~
compilation terminated.
In file included from /home/shuvo/Documents/ML Project/Face_Recognition/dlib/dlib/external/pybind11/include/pybind11/attr.h:13,
from /home/shuvo/Documents/ML Project/Face_Recognition/dlib/dlib/external/pybind11/include/pybind11/detail/class.h:12,
from /home/shuvo/Documents/ML Project/Face_Recognition/dlib/dlib/external/pybind11/include/pybind11/pybind11.h:13,
from /home/shuvo/Documents/ML Project/Face_Recognition/dlib/dlib/../dlib/python/pybind_utils.h:6,
from /home/shuvo/Documents/ML Project/Face_Recognition/dlib/dlib/../dlib/python.h:6,
from /home/shuvo/Documents/ML Project/Face_Recognition/dlib/tools/python/src/opaque_types.h:6,
from /home/shuvo/Documents/ML Project/Face_Recognition/dlib/tools/python/src/vector.cpp:4:
/home/shuvo/Documents/ML Project/Face_Recognition/dlib/dlib/external/pybind11/include/pybind11/detail/common.h:274:10: fatal error: Python.h: No such file or directory
274 | #include <Python.h>
| ^~~~~~~~~~
compilation terminated.
In file included from /home/shuvo/Documents/ML Project/Face_Recognition/dlib/dlib/external/pybind11/include/pybind11/attr.h:13,
from /home/shuvo/Documents/ML Project/Face_Recognition/dlib/dlib/external/pybind11/include/pybind11/detail/class.h:12,
from /home/shuvo/Documents/ML Project/Face_Recognition/dlib/dlib/external/pybind11/include/pybind11/pybind11.h:13,
from /home/shuvo/Documents/ML Project/Face_Recognition/dlib/dlib/../dlib/python/pybind_utils.h:6,
from /home/shuvo/Documents/ML Project/Face_Recognition/dlib/dlib/../dlib/python.h:6,
from /home/shuvo/Documents/ML Project/Face_Recognition/dlib/tools/python/src/opaque_types.h:6,
from /home/shuvo/Documents/ML Project/Face_Recognition/dlib/tools/python/src/matrix.cpp:4:
/home/shuvo/Documents/ML Project/Face_Recognition/dlib/dlib/external/pybind11/include/pybind11/detail/common.h:274:10: fatal error: Python.h: No such file or directory
274 | #include <Python.h>
| ^~~~~~~~~~
compilation terminated.
gmake[2]: *** [CMakeFiles/_dlib_pybind11.dir/build.make:90: CMakeFiles/_dlib_pybind11.dir/src/matrix.cpp.o] Error 1
gmake[2]: *** Waiting for unfinished jobs....
gmake[2]: *** [CMakeFiles/_dlib_pybind11.dir/build.make:76: CMakeFiles/_dlib_pybind11.dir/src/dlib.cpp.o] Error 1
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:104: CMakeFiles/_dlib_pybind11.dir/src/vector.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/shuvo/Documents/ML Project/Face_Recognition/dlib/setup.py", line 206, in
setup(
File "/home/shuvo/Documents/ML Project/Face_Recognition/venv/lib/python3.10/site-packages/setuptools/init.py", line 108, in setup
return distutils.core.setup(**attrs)
File "/home/shuvo/Documents/ML Project/Face_Recognition/venv/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 184, in setup
return run_commands(dist)
File "/home/shuvo/Documents/ML Project/Face_Recognition/venv/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 200, in run_commands
dist.run_commands()
File "/home/shuvo/Documents/ML Project/Face_Recognition/venv/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 970, in run_commands
self.run_command(cmd)
File "/home/shuvo/Documents/ML Project/Face_Recognition/venv/lib/python3.10/site-packages/setuptools/dist.py", line 945, in run_command
super().run_command(command)
File "/home/shuvo/Documents/ML Project/Face_Recognition/venv/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 989, in run_command
cmd_obj.run()
File "/home/shuvo/Documents/ML Project/Face_Recognition/venv/lib/python3.10/site-packages/setuptools/command/install.py", line 92, in run
self.do_egg_install()
File "/home/shuvo/Documents/ML Project/Face_Recognition/venv/lib/python3.10/site-packages/setuptools/command/install.py", line 144, in do_egg_install
self.run_command('bdist_egg')
File "/home/shuvo/Documents/ML Project/Face_Recognition/venv/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command
self.distribution.run_command(command)
File "/home/shuvo/Documents/ML Project/Face_Recognition/venv/lib/python3.10/site-packages/setuptools/dist.py", line 945, in run_command
super().run_command(command)
File "/home/shuvo/Documents/ML Project/Face_Recognition/venv/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 989, in run_command
cmd_obj.run()
File "/home/shuvo/Documents/ML Project/Face_Recognition/venv/lib/python3.10/site-packages/setuptools/command/bdist_egg.py", line 167, in run
cmd = self.call_command('install_lib', warn_dir=False)
File "/home/shuvo/Documents/ML Project/Face_Recognition/venv/lib/python3.10/site-packages/setuptools/command/bdist_egg.py", line 153, in call_command
self.run_command(cmdname)
File "/home/shuvo/Documents/ML Project/Face_Recognition/venv/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command
self.distribution.run_command(command)
File "/home/shuvo/Documents/ML Project/Face_Recognition/venv/lib/python3.10/site-packages/setuptools/dist.py", line 945, in run_command
super().run_command(command)
File "/home/shuvo/Documents/ML Project/Face_Recognition/venv/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 989, in run_command
cmd_obj.run()
File "/home/shuvo/Documents/ML Project/Face_Recognition/venv/lib/python3.10/site-packages/setuptools/command/install_lib.py", line 13, in run
self.build()
File "/home/shuvo/Documents/ML Project/Face_Recognition/venv/lib/python3.10/site-packages/setuptools/_distutils/command/install_lib.py", line 110, in build
self.run_command('build_ext')
File "/home/shuvo/Documents/ML Project/Face_Recognition/venv/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command
self.distribution.run_command(command)
File "/home/shuvo/Documents/ML Project/Face_Recognition/venv/lib/python3.10/site-packages/setuptools/dist.py", line 945, in run_command
super().run_command(command)
File "/home/shuvo/Documents/ML Project/Face_Recognition/venv/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 989, in run_command
cmd_obj.run()
File "/home/shuvo/Documents/ML Project/Face_Recognition/dlib/setup.py", line 130, in run
self.build_extension(ext)
File "/home/shuvo/Documents/ML Project/Face_Recognition/dlib/setup.py", line 171, 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', '--', '-j4']' returned non-zero exit status 2

@liwg1995
Copy link

liwg1995 commented Aug 3, 2024 via email

@genghaifei
Copy link

genghaifei commented Aug 19, 2024

need gcc version 10 and cmake version 3.9

@liwg1995
Copy link

liwg1995 commented Aug 19, 2024 via email

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