dlib: dlib fails to install on Windows 10

Expected Behavior

Expected dlib to be instalable on Windows 10 running Python 3.6 (as a conda virtual env) with command: pip install dlib. Have installed cmake and numpy as prerequisites. This failed with:

(py36) PS C:\Users\Jean Claude> pip install dlib Collecting dlib Using cached dlib-19.22.0.tar.gz (7.4 MB) Building wheels for collected packages: dlib Building wheel for dlib (setup.py) … error ERROR: Command errored out with exit status 1: command: ‘C:\Users\Jean Claude\anaconda3\envs\py36\python.exe’ -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’“‘C:\Users\JEANCL~1\AppData\Local\Temp\pip-install-bdv23ese\dlib_6034d75b85f2455eaa1e85e06b14242b\setup.py’”’“‘; file=’”‘“‘C:\Users\JEANCL~1\AppData\Local\Temp\pip-install-bdv23ese\dlib_6034d75b85f2455eaa1e85e06b14242b\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 ‘C:\Users\JEANCL~1\AppData\Local\Temp\pip-wheel-03d14jpb’ cwd: C:\Users\JEANCL~1\AppData\Local\Temp\pip-install-bdv23ese\dlib_6034d75b85f2455eaa1e85e06b14242b
Complete output (58 lines): running bdist_wheel running build running build_py package init file ‘tools\python\dlib_init_.py’ not found (or not a regular file) running build_ext Building extension for Python 3.6.13 |Anaconda, Inc.| (default, Mar 16 2021, 11:37:27) [MSC v.1916 64 bit (AMD64)] Invoking CMake setup: ‘cmake C:\Users\JEANCL~1\AppData\Local\Temp\pip-install-bdv23ese\dlib_6034d75b85f2455eaa1e85e06b14242b\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\JEANCL~1\AppData\Local\Temp\pip-install-bdv23ese\dlib_6034d75b85f2455eaa1e85e06b14242b\build\lib.win-amd64-3.6 -DPYTHON_EXECUTABLE=C:\Users\Jean Claude\anaconda3\envs\py36\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\JEANCL~1\AppData\Local\Temp\pip-install-bdv23ese\dlib_6034d75b85f2455eaa1e85e06b14242b\build\lib.win-amd64-3.6 -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 “<string>”, line 1, in <module> File “C:\Users\JEANCL~1\AppData\Local\Temp\pip-install-bdv23ese\dlib_6034d75b85f2455eaa1e85e06b14242b\setup.py”, line 261, in <module> ‘Topic :: Software Development’, File “C:\Users\Jean Claude\anaconda3\envs\py36\lib\site-packages\setuptools_init_.py”, line 153, in setup return distutils.core.setup(**attrs) File “C:\Users\Jean Claude\anaconda3\envs\py36\lib\distutils\core.py”, line 148, in setup dist.run_commands() File “C:\Users\Jean Claude\anaconda3\envs\py36\lib\distutils\dist.py”, line 955, in run_commands self.run_command(cmd) File “C:\Users\Jean Claude\anaconda3\envs\py36\lib\distutils\dist.py”, line 974, in run_command cmd_obj.run() File “C:\Users\Jean Claude\anaconda3\envs\py36\lib\site-packages\wheel\bdist_wheel.py”, line 299, in run self.run_command(‘build’) File “C:\Users\Jean Claude\anaconda3\envs\py36\lib\distutils\cmd.py”, line 313, in run_command self.distribution.run_command(command) File “C:\Users\Jean Claude\anaconda3\envs\py36\lib\distutils\dist.py”, line 974, in run_command cmd_obj.run() File “C:\Users\Jean Claude\anaconda3\envs\py36\lib\distutils\command\build.py”, line 135, in run self.run_command(cmd_name) File “C:\Users\Jean Claude\anaconda3\envs\py36\lib\distutils\cmd.py”, line 313, in run_command self.distribution.run_command(command) File “C:\Users\Jean Claude\anaconda3\envs\py36\lib\distutils\dist.py”, line 974, in run_command cmd_obj.run() File “C:\Users\JEANCL~1\AppData\Local\Temp\pip-install-bdv23ese\dlib_6034d75b85f2455eaa1e85e06b14242b\setup.py”, line 134, in run self.build_extension(ext) File “C:\Users\JEANCL~1\AppData\Local\Temp\pip-install-bdv23ese\dlib_6034d75b85f2455eaa1e85e06b14242b\setup.py”, line 171, in build_extension subprocess.check_call(cmake_setup, cwd=build_folder) File “C:\Users\Jean Claude\anaconda3\envs\py36\lib\subprocess.py”, line 311, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command ‘[‘cmake’, ‘C:\Users\JEANCL~1\AppData\Local\Temp\pip-install-bdv23ese\dlib_6034d75b85f2455eaa1e85e06b14242b\tools\python’, ‘-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\JEANCL~1\AppData\Local\Temp\pip-install-bdv23ese\dlib_6034d75b85f2455eaa1e85e06b14242b\build\lib.win-amd64-3.6’, ‘-DPYTHON_EXECUTABLE=C:\Users\Jean Claude\anaconda3\envs\py36\python.exe’, ‘-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\JEANCL~1\AppData\Local\Temp\pip-install-bdv23ese\dlib_6034d75b85f2455eaa1e85e06b14242b\build\lib.win-amd64-3.6’, ‘-A’, ‘x64’]’ returned non-zero exit status 1.

ERROR: Failed building wheel for dlib Running setup.py clean for dlib Failed to build dlib Installing collected packages: dlib Running setup.py install for dlib … error ERROR: Command errored out with exit status 1: command: ‘C:\Users\Jean Claude\anaconda3\envs\py36\python.exe’ -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’“‘C:\Users\JEANCL~1\AppData\Local\Temp\pip-install-bdv23ese\dlib_6034d75b85f2455eaa1e85e06b14242b\setup.py’”’“‘; file=’”‘“‘C:\Users\JEANCL~1\AppData\Local\Temp\pip-install-bdv23ese\dlib_6034d75b85f2455eaa1e85e06b14242b\setup.py’”’“';f=getattr(tokenize, '”‘“‘open’”’“‘, open)(file);code=f.read().replace(’”‘"’\r\n’“'”‘, ‘"’"’\n’“'”‘);f.close();exec(compile(code, file, ‘"’“‘exec’”’"‘))’ install --record ‘C:\Users\JEANCL~1\AppData\Local\Temp\pip-record-odoruwut\install-record.txt’ --single-version-externally-managed --compile --install-headers ‘C:\Users\Jean Claude\anaconda3\envs\py36\Include\dlib’ cwd: C:\Users\JEANCL~1\AppData\Local\Temp\pip-install-bdv23ese\dlib_6034d75b85f2455eaa1e85e06b14242b
Complete output (60 lines): running install running build running build_py package init file ‘tools\python\dlib_init_.py’ not found (or not a regular file) running build_ext Building extension for Python 3.6.13 |Anaconda, Inc.| (default, Mar 16 2021, 11:37:27) [MSC v.1916 64 bit (AMD64)] Invoking CMake setup: ‘cmake C:\Users\JEANCL~1\AppData\Local\Temp\pip-install-bdv23ese\dlib_6034d75b85f2455eaa1e85e06b14242b\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\JEANCL~1\AppData\Local\Temp\pip-install-bdv23ese\dlib_6034d75b85f2455eaa1e85e06b14242b\build\lib.win-amd64-3.6 -DPYTHON_EXECUTABLE=C:\Users\Jean Claude\anaconda3\envs\py36\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\JEANCL~1\AppData\Local\Temp\pip-install-bdv23ese\dlib_6034d75b85f2455eaa1e85e06b14242b\build\lib.win-amd64-3.6 -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 "<string>", line 1, in <module>
  File "C:\Users\JEANCL~1\AppData\Local\Temp\pip-install-bdv23ese\dlib_6034d75b85f2455eaa1e85e06b14242b\setup.py", line 261, in <module>
    'Topic :: Software Development',
  File "C:\Users\Jean Claude\anaconda3\envs\py36\lib\site-packages\setuptools\__init__.py", line 153, in setup
    return distutils.core.setup(**attrs)
  File "C:\Users\Jean Claude\anaconda3\envs\py36\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "C:\Users\Jean Claude\anaconda3\envs\py36\lib\distutils\dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "C:\Users\Jean Claude\anaconda3\envs\py36\lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
  File "C:\Users\Jean Claude\anaconda3\envs\py36\lib\site-packages\setuptools\command\install.py", line 61, in run
    return orig.install.run(self)
  File "C:\Users\Jean Claude\anaconda3\envs\py36\lib\distutils\command\install.py", line 545, in run
    self.run_command('build')
  File "C:\Users\Jean Claude\anaconda3\envs\py36\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "C:\Users\Jean Claude\anaconda3\envs\py36\lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
  File "C:\Users\Jean Claude\anaconda3\envs\py36\lib\distutils\command\build.py", line 135, in run
    self.run_command(cmd_name)
  File "C:\Users\Jean Claude\anaconda3\envs\py36\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "C:\Users\Jean Claude\anaconda3\envs\py36\lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
  File "C:\Users\JEANCL~1\AppData\Local\Temp\pip-install-bdv23ese\dlib_6034d75b85f2455eaa1e85e06b14242b\setup.py", line 134, in run
    self.build_extension(ext)
  File "C:\Users\JEANCL~1\AppData\Local\Temp\pip-install-bdv23ese\dlib_6034d75b85f2455eaa1e85e06b14242b\setup.py", line 171, in build_extension
    subprocess.check_call(cmake_setup, cwd=build_folder)
  File "C:\Users\Jean Claude\anaconda3\envs\py36\lib\subprocess.py", line 311, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\JEANCL~1\\AppData\\Local\\Temp\\pip-install-bdv23ese\\dlib_6034d75b85f2455eaa1e85e06b14242b\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\JEANCL~1\\AppData\\Local\\Temp\\pip-install-bdv23ese\\dlib_6034d75b85f2455eaa1e85e06b14242b\\build\\lib.win-amd64-3.6', '-DPYTHON_EXECUTABLE=C:\\Users\\Jean Claude\\anaconda3\\envs\\py36\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\JEANCL~1\\AppData\\Local\\Temp\\pip-install-bdv23ese\\dlib_6034d75b85f2455eaa1e85e06b14242b\\build\\lib.win-amd64-3.6', '-A', 'x64']' returned non-zero exit status 1.
----------------------------------------

ERROR: Command errored out with exit status 1: ‘C:\Users\Jean Claude\anaconda3\envs\py36\python.exe’ -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’“‘C:\Users\JEANCL~1\AppData\Local\Temp\pip-install-bdv23ese\dlib_6034d75b85f2455eaa1e85e06b14242b\setup.py’”’“‘; file=’”‘“‘C:\Users\JEANCL~1\AppData\Local\Temp\pip-install-bdv23ese\dlib_6034d75b85f2455eaa1e85e06b14242b\setup.py’”’“';f=getattr(tokenize, '”‘“‘open’”’“‘, open)(file);code=f.read().replace(’”‘"’\r\n’“'”‘, ‘"’"’\n’“'”‘);f.close();exec(compile(code, file, ‘"’“‘exec’”’"‘))’ install --record ‘C:\Users\JEANCL~1\AppData\Local\Temp\pip-record-odoruwut\install-record.txt’ --single-version-externally-managed --compile --install-headers ‘C:\Users\Jean Claude\anaconda3\envs\py36\Include\dlib’ Check the logs for full command output.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (3 by maintainers)

Most upvoted comments

Install Visual Studio Community (classic C++ option) fisrt for free and be blessed.

Please reopen this. This is an ongoing issue with lots of assumptions made, the first being that “The Universe uses Visual Studio.” This is not true.

I am running the following environment:

  • Windows 10 Pro 21h2 64 bits

    • Intel® Celeron® CPU 4205U @ 1.80GHz 1.80 GHz
    • 8GB RAM
  • Python 3.9.9

  • CMake version 3.18.4

  • VS Community 2022 17.0.2

  • VS Build Tools 2022 17.0.2

I do poetry install, and my pyproject.toml targets 19.21.1. I get:

  • Installing dlib (19.21.1)

  EnvCommandError
[...]
    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++.


      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[...]

I’m a Python developer. I do not do C++ at all. I do not use Visual Studio at all. I’m trying to install dlib in a brand new Intel NUC (an embedded device, with limited resources) and simply put there are no clear end-to-end instructions or even fuzzy guidelines as to what exactly do in order to achieve this greenfield, from scratch, zero assumptions, foolproof.

I find it preposterous that the general rule is a blanket “Install VS 20##”, ignoring the simple fact that we’re being asked to install a sixteen gigabytes full IDE in order to compile what amounts to an 8MB .pyc. Is this just me?

I understand that different HW configurations require different compilations and that therefore dlib is not distributed ready compiled, like numpy, pandas or OpenCV, but at the very least a serious and responsible guide to an absolute minimum prerequisite installation would be interesting. I’m not sure how big a VS installation configuration file would be, but that would also be grand.

Alternatively, is there any other compiler that doesn’t use up the entire disk? Something non-IDE and non-Microsoft that could be used in such cases? I’m thinking of something along the lines of Linux gcc that would compile dlib.

Any suggestions would be highly appreciated. As it stands, I am forced to carry around a .pyc file on my project’s repository, and this just feels wrong.

Again, thank you for replying on a Sunday, and join the club! It is not clear to me either what could it be that is hanging up, but as per my trace above, the system keeps claiming that I must install VS for C++, despite all the time I spent doing just that.

Worse: it is working on my laptop, but not on any of the embedded devices.

UPDATE: isn’t it always something small and slightly humiliating? The issue was mismatched versions. CMake 3.18.4 supports as high as VS 16 (2019), same as I have on my laptop. However, on the devices I’m using VS 17 (2022). All it took was to get the latest CMake 3.22.1 and it immediately started working.

You might think you didn’t do much, but you helped. Thank you very much!