Facing the following error while installing dlib for the OpenCV project. It shows that
CMake must be installed to build the following extensions: dlib.
Command Output:
Collecting dlib==19.18.0
Using cached dlib-19.18.0.tar.gz (3.1 MB)
Using legacy 'setup.py install' for dlib, since package 'wheel' is not installed.
Installing collected packages: dlib
Running setup.py install for dlib: started
Running setup.py install for dlib: finished with status 'error'
ERROR: Command errored out with exit status 1:
command: 'D:Install Drivepython.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\mahmu\AppData\Local\Temp\pip-install-a4s1a_zh\dlib\setup.py'"'"'; __file__='"'"'C:\Users\mahmu\AppData\Local\Temp\pip-install-a4s1a_zh\dlib\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:UsersmahmuAppDataLocalTemppip-record-mjm6k3c3install-record.txt' --single-version-externally-managed --compile --install-headers 'D:Install DriveIncludedlib'
cwd: C:UsersmahmuAppDataLocalTemppip-install-a4s1a_zhdlib
Complete output (57 lines):
running install
running build
running build_py
package init file 'dlib__init__.py' not found (or not a regular file)
warning: build_py: byte-compiling is disabled, skipping.
running build_ext
Traceback (most recent call last):
File "C:UsersmahmuAppDataLocalTemppip-install-a4s1a_zhdlibsetup.py", line 120, in get_cmake_version
out = subprocess.check_output(['cmake', '--version'])
File "D:Install Drivelibsubprocess.py", line 424, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "D:Install Drivelibsubprocess.py", line 505, in run
with Popen(*popenargs, **kwargs) as process:
File "D:Install Drivelibsubprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "D:Install Drivelibsubprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:UsersmahmuAppDataLocalTemppip-install-a4s1a_zhdlibsetup.py", line 223, in <module>
setup(
File "D:Install Drivelibsite-packagessetuptools__init__.py", line 165, in setup
return distutils.core.setup(**attrs)
File "D:Install Drivelibdistutilscore.py", line 148, in setup
dist.run_commands()
File "D:Install Drivelibdistutilsdist.py", line 966, in run_commands
self.run_command(cmd)
File "D:Install Drivelibdistutilsdist.py", line 985, in run_command
cmd_obj.run()
File "D:Install Drivelibsite-packagessetuptoolscommandinstall.py", line 61, in run
return orig.install.run(self)
File "D:Install Drivelibdistutilscommandinstall.py", line 546, in run
self.run_command('build')
File "D:Install Drivelibdistutilscmd.py", line 313, in run_command
self.distribution.run_command(command)
File "D:Install Drivelibdistutilsdist.py", line 985, in run_command
cmd_obj.run()
File "D:Install Drivelibdistutilscommandbuild.py", line 135, in run
self.run_command(cmd_name)
File "D:Install Drivelibdistutilscmd.py", line 313, in run_command
self.distribution.run_command(command)
File "D:Install Drivelibdistutilsdist.py", line 985, in run_command
cmd_obj.run()
File "C:UsersmahmuAppDataLocalTemppip-install-a4s1a_zhdlibsetup.py", line 129, in run
cmake_version = self.get_cmake_version()
File "C:UsersmahmuAppDataLocalTemppip-install-a4s1a_zhdlibsetup.py", line 122, in get_cmake_version
raise RuntimeError("n*******************************************************************n" +
RuntimeError:
*******************************************************************
CMake must be installed to build the following extensions: dlib
*******************************************************************
----------------------------------------
ERROR: Command errored out with exit status 1: 'D:Install Drivepython.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\mahmu\AppData\Local\Temp\pip-install-a4s1a_zh\dlib\setup.py'"'"'; __file__='"'"'C:\Users\mahmu\AppData\Local\Temp\pip-install-a4s1a_zh\dlib\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:UsersmahmuAppDataLocalTemppip-record-mjm6k3c3install-record.txt' --single-version-externally-managed --compile --install-headers 'D:Install DriveIncludedlib' Check the logs for full command output.
WARNING: You are using pip version 20.2.3; however, version 21.1.2 is available.
You should consider upgrading via the 'D:Install Drivepython.exe -m pip install --upgrade pip' command.
1
It requires cmake must be installed before installing dlib. Do execute in the following order.
pip install cmake
pip install dlib
This will fix the issue.
Notice that in the output that “CMake must be installed to build the following extensions: dlib”. So install CMake first and only then try to install dlib. If CMake is installed, try updating your pip version to 21.1.2 via “D:Install Drivepython.exe -m pip install –upgrade pip”.