'dlib not installing (cmake)
Hi I am trying to install dlib via cmake but I keep getting error: legacy-install-failure here is the full readout (I have replaced my actual user name with USER)
>C:\Users\USER->pip install dlib
Collecting dlib
Using cached dlib-19.23.1.tar.gz (7.4 MB)
Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for dlib, since package 'wheel' is not installed.
Installing collected packages: dlib
Running setup.py install for dlib ... error
error: subprocess-exited-with-error
× Running setup.py install for dlib did not run successfully.
│ exit code: 1
╰─> [73 lines of output]
running install
C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
running build
running build_py
package init file 'tools\python\dlib\__init__.py' not found (or not a regular file)
running build_ext
C:\Users\USER-\AppData\Local\Temp\pip-install-q7gocxf3\dlib_ba1eccb06b884bc4a89365e82ab2b34f\setup.py:129: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
if LooseVersion(cmake_version) < '3.1.0':
Building extension for Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)]
Invoking CMake setup: 'cmake C:\Users\USER-\AppData\Local\Temp\pip-install-q7gocxf3\dlib_ba1eccb06b884bc4a89365e82ab2b34f\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\USER-\AppData\Local\Temp\pip-install-q7gocxf3\dlib_ba1eccb06b884bc4a89365e82ab2b34f\build\lib.win-amd64-3.10 -DPYTHON_EXECUTABLE=C:\Users\USER-\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\USER-\AppData\Local\Temp\pip-install-q7gocxf3\dlib_ba1eccb06b884bc4a89365e82ab2b34f\build\lib.win-amd64-3.10 -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 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "C:\Users\USER-\AppData\Local\Temp\pip-install-q7gocxf3\dlib_ba1eccb06b884bc4a89365e82ab2b34f\setup.py", line 222, in <module>
setup(
File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\__init__.py", line 79, in setup
return distutils.core.setup(**attrs)
File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\_distutils\core.py", line 148, in setup
return run_commands(dist)
File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\_distutils\core.py", line 163, in run_commands
dist.run_commands()
File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\_distutils\dist.py", line 967, in run_commands
self.run_command(cmd)
File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\dist.py", line 1196, in run_command
super().run_command(command)
File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
cmd_obj.run()
File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\command\install.py", line 68, in run
return orig.install.run(self)
File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\_distutils\command\install.py", line 670, in run
self.run_command('build')
File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\_distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\dist.py", line 1196, in run_command
super().run_command(command)
File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
cmd_obj.run()
File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\_distutils\command\build.py", line 135, in run
self.run_command(cmd_name)
File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\_distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\dist.py", line 1196, in run_command
super().run_command(command)
File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
cmd_obj.run()
File "C:\Users\USER-\AppData\Local\Temp\pip-install-q7gocxf3\dlib_ba1eccb06b884bc4a89365e82ab2b34f\setup.py", line 134, in run
self.build_extension(ext)
File "C:\Users\USER-\AppData\Local\Temp\pip-install-q7gocxf3\dlib_ba1eccb06b884bc4a89365e82ab2b34f\setup.py", line 171, in build_extension
subprocess.check_call(cmake_setup, cwd=build_folder)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 369, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\USER-\\AppData\\Local\\Temp\\pip-install-q7gocxf3\\dlib_ba1eccb06b884bc4a89365e82ab2b34f\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\USER-\\AppData\\Local\\Temp\\pip-install-q7gocxf3\\dlib_ba1eccb06b884bc4a89365e82ab2b34f\\build\\lib.win-amd64-3.10', '-DPYTHON_EXECUTABLE=C:\\Users\\USER-\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\USER-\\AppData\\Local\\Temp\\pip-install-q7gocxf3\\dlib_ba1eccb06b884bc4a89365e82ab2b34f\\build\\lib.win-amd64-3.10', '-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: legacy-install-failure
× Encountered error while trying to install package.
╰─> dlib
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
Solution 1:[1]
Dlib documentation says:
We should also make a special note of the problems associated with using precompiled C++ libraries with Visual Studio. The TLDR is that you should not use precompiled libraries (i.e. .lib files) with Visual Studio unless you really know what you are doing. This is not a dlib limitation. It has nothing to do with dlib. It's just how Visual Studio works. Please do not ask me about it. If you want to understand this you should read the Visual Studio documentation and this excellent overview in particular.
With that beeing said, it's likely they don't ship precompiled library with their installers, and it order to use it on windows you have to compile it yourself, and to compile it you need Visual Studio (mingw or clang wont work).
If you dont mind installing another instance of python in your system, you can use conda to get precompiled dlib.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | mugiseyebrows |
