getting Error in installing Dlib using pip

Question:

C:Userssuraj>pip install dlib
Collecting dlib
  Using cached https://files.pythonhosted.org/packages/35/8d/e4ddf60452e2fb1ce3164f774e68968b3f110f1cb4cd353235d56875799e/dlib-19.16.0.tar.gz
Building wheels for collected packages: dlib
  Running setup.py bdist_wheel for dlib ... error
  Complete output from command c:userssurajappdatalocalprogramspythonpython37python.exe -u -c "import setuptools, tokenize;__file__='C:\Users\suraj\AppData\Local\Temp\pip-install-ytzp5t26\dlib\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('rn', 'n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:UserssurajAppDataLocalTemppip-wheel-mu6pctca --python-tag cp37:
  running bdist_wheel
  running build
  running build_py
  package init file 'dlib__init__.py' not found (or not a regular file)
  running build_ext
  Building extension for Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)]
  Invoking CMake setup: 'cmake C:UserssurajAppDataLocalTemppip-install-ytzp5t26dlibtoolspython -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:UserssurajAppDataLocalTemppip-install-ytzp5t26dlibbuildlib.win-amd64-3.7 -DPYTHON_EXECUTABLE=c:userssurajappdatalocalprogramspythonpython37python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:UserssurajAppDataLocalTemppip-install-ytzp5t26dlibbuildlib.win-amd64-3.7 -A x64'
  -- Building for: NMake Makefiles
  CMake Error in CMakeLists.txt:
    Generator

      NMake Makefiles

    **does not support platform specification, but platform
      x64**

    was specified.


  **CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
  CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage**
  -- Configuring incomplete, errors occurred!
  See also "C:/Users/suraj/AppData/Local/Temp/pip-install-ytzp5t26/dlib/build/temp.win-amd64-3.7/Release/CMakeFiles/CMakeOutput.log".
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:UserssurajAppDataLocalTemppip-install-ytzp5t26dlibsetup.py", line 257, in <module>
      'Topic :: Software Development',
    File "c:userssurajappdatalocalprogramspythonpython37libsite-packagessetuptools__init__.py", line 143, in setup
      return distutils.core.setup(**attrs)
    File "c:userssurajappdatalocalprogramspythonpython37libdistutilscore.py", line 148, in setup
      dist.run_commands()
    File "c:userssurajappdatalocalprogramspythonpython37libdistutilsdist.py", line 966, in run_commands
      self.run_command(cmd)
    File "c:userssurajappdatalocalprogramspythonpython37libdistutilsdist.py", line 985, in run_command
      cmd_obj.run()
    File "c:userssurajappdatalocalprogramspythonpython37libsite-packageswheelbdist_wheel.py", line 188, in run
      self.run_command('build')
    File "c:userssurajappdatalocalprogramspythonpython37libdistutilscmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "c:userssurajappdatalocalprogramspythonpython37libdistutilsdist.py", line 985, in run_command
      cmd_obj.run()
    File "c:userssurajappdatalocalprogramspythonpython37libdistutilscommandbuild.py", line 135, in run
      self.run_command(cmd_name)
    File "c:userssurajappdatalocalprogramspythonpython37libdistutilscmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "c:userssurajappdatalocalprogramspythonpython37libdistutilsdist.py", line 985, in run_command
      cmd_obj.run()
    File "C:UserssurajAppDataLocalTemppip-install-ytzp5t26dlibsetup.py", line 133, in run
      self.build_extension(ext)
    File "C:UserssurajAppDataLocalTemppip-install-ytzp5t26dlibsetup.py", line 170, in build_extension
      subprocess.check_call(cmake_setup, cwd=build_folder)
    File "c:userssurajappdatalocalprogramspythonpython37libsubprocess.py", line 347, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['cmake', 'C:\Users\suraj\AppData\Local\Temp\pip-install-ytzp5t26\dlib\tools\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\suraj\AppData\Local\Temp\pip-install-ytzp5t26\dlib\build\lib.win-amd64-3.7', '-DPYTHON_EXECUTABLE=c:\users\suraj\appdata\local\programs\python\python37\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\suraj\AppData\Local\Temp\pip-install-ytzp5t26\dlib\build\lib.win-amd64-3.7', '-A', 'x64']' returned non-zero exit status 1.

  ----------------------------------------
  **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
    Complete output from command c:userssurajappdatalocalprogramspythonpython37python.exe -u -c "import setuptools, tokenize;__file__='C:\Users\suraj\AppData\Local\Temp\pip-install-ytzp5t26\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:UserssurajAppDataLocalTemppip-record-adx5_t4vinstall-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    package init file 'dlib__init__.py' not found (or not a regular file)
    running build_ext
    Building extension for Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)]
    Invoking CMake setup: 'cmake C:UserssurajAppDataLocalTemppip-install-ytzp5t26dlibtoolspython -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:UserssurajAppDataLocalTemppip-install-ytzp5t26dlibbuildlib.win-amd64-3.7 -DPYTHON_EXECUTABLE=c:userssurajappdatalocalprogramspythonpython37python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:UserssurajAppDataLocalTemppip-install-ytzp5t26dlibbuildlib.win-amd64-3.7 -A x64'
    -- Building for: NMake Makefiles
    CMake Error in CMakeLists.txt:
      Generator

        NMake Makefiles

      does not support platform specification, but platform

        x64

      was specified.


    CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
    CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
    -- Configuring incomplete, errors occurred!
    See also "C:/Users/suraj/AppData/Local/Temp/pip-install-ytzp5t26/dlib/build/temp.win-amd64-3.7/Release/CMakeFiles/CMakeOutput.log".
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:UserssurajAppDataLocalTemppip-install-ytzp5t26dlibsetup.py", line 257, in <module>
        'Topic :: Software Development',
      File "c:userssurajappdatalocalprogramspythonpython37libsite-packagessetuptools__init__.py", line 143, in setup
        return distutils.core.setup(**attrs)
      File "c:userssurajappdatalocalprogramspythonpython37libdistutilscore.py", line 148, in setup
        dist.run_commands()
      File "c:userssurajappdatalocalprogramspythonpython37libdistutilsdist.py", line 966, in run_commands
        self.run_command(cmd)
      File "c:userssurajappdatalocalprogramspythonpython37libdistutilsdist.py", line 985, in run_command
        cmd_obj.run()
      File "c:userssurajappdatalocalprogramspythonpython37libsite-packagessetuptoolscommandinstall.py", line 61, in run
        return orig.install.run(self)
      File "c:userssurajappdatalocalprogramspythonpython37libdistutilscommandinstall.py", line 545, in run
        self.run_command('build')
      File "c:userssurajappdatalocalprogramspythonpython37libdistutilscmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "c:userssurajappdatalocalprogramspythonpython37libdistutilsdist.py", line 985, in run_command
        cmd_obj.run()
      File "c:userssurajappdatalocalprogramspythonpython37libdistutilscommandbuild.py", line 135, in run
        self.run_command(cmd_name)
      File "c:userssurajappdatalocalprogramspythonpython37libdistutilscmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "c:userssurajappdatalocalprogramspythonpython37libdistutilsdist.py", line 985, in run_command
        cmd_obj.run()
      File "C:UserssurajAppDataLocalTemppip-install-ytzp5t26dlibsetup.py", line 133, in run
        self.build_extension(ext)
      File "C:UserssurajAppDataLocalTemppip-install-ytzp5t26dlibsetup.py", line 170, in build_extension
        subprocess.check_call(cmake_setup, cwd=build_folder)
      File "c:userssurajappdatalocalprogramspythonpython37libsubprocess.py", line 347, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['cmake', 'C:\Users\suraj\AppData\Local\Temp\pip-install-ytzp5t26\dlib\tools\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\suraj\AppData\Local\Temp\pip-install-ytzp5t26\dlib\build\lib.win-amd64-3.7', '-DPYTHON_EXECUTABLE=c:\users\suraj\appdata\local\programs\python\python37\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\suraj\AppData\Local\Temp\pip-install-ytzp5t26\dlib\build\lib.win-amd64-3.7', '-A', 'x64']' returned non-zero exit status 1.

    ----------------------------------------
Command "c:userssurajappdatalocalprogramspythonpython37python.exe -u -c "import setuptools, tokenize;__file__='C:\Users\suraj\AppData\Local\Temp\pip-install-ytzp5t26\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:UserssurajAppDataLocalTemppip-record-adx5_t4vinstall-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:UserssurajAppDataLocalTemppip-install-ytzp5t26dlib

This is the Error I’m getting while installing dlib using pip in command prompt.
I already have openCV and matplotlib and numpy.

Asked By: Suraj Singh

||

Answers:

I faced many error while installing dlib and solve by using below .whl:

 pip install https://pypi.python.org/packages/da/06/bd3e241c4eb0a662914b3b4875fc52dd176a9db0d4a2c915ac2ad8800e9e/dlib-19.7.0-cp36-cp36m-win_amd64.whl#md5=b7330a5b2d46420343fbed5df69e6a3f

Download wheel from this link

This might help 🙂

Answered By: Nusrath

I faced the same problem a while back. I did a few things and it worked

  1. Install C and C++ compilers and add them to path.

  2. Install visual studio 2015 (VS2015) down-loader. (any other version might not work). This stack overflow thread may help: How to download Visual Studio Community Edition 2015 (not 2017)

  3. Install all the dependencies through VS2015.(support for C, C++, MS Build, windows SDK etc)

  4. Try and use pip install dlib again.

I hope this helps!

Answered By: Aprajita Verma

You may need to install cmake first: “pip install cmake

Then install dlib i.e: “pip install dlib“.

Will surely work 100%.

Note: You must have a fast processor for building wheel else it’ll take more than 5mins.

Answered By: Saif Ur Rehman

For those who are facing the same problem but using mac OS –> I did the below steps and resolved the same issue. I have macOS Big Sur 11.1 with python 3.8.3.

pip3 install cmake 
pip3 install dlib
Answered By: Hailey Yoon

OK for the record here: On debian 10. pip install dlib fails even with pip install cmake first. Solution? sudo apt install libopenblas-dev. The output of pip install dlib --verbose mentions it as an optional install that makes your code run faster. Turns out without installing this first the install fails every time. With it the install succeeds.

Answered By: Dom

download cmake executable file on your pc, install it and install cmake build tools for c++ from visual studio build tools. After installing cmake with visual studio build tools, you can download the wheel file from this github repo: https://github.com/Tobyyosoba777/Computer-Vision-OpenCv-Python-/tree/main/Libraries

download: dlib-19.22.99-cp39-cp39-win_amd64.whl

and download: dlib-19.22.99.win-amd64-py3.9.exe

install the .exe file on your pc, restart it(not necessary) and open the current directory of the downloaded .whl file where it is saved on your pc in your python/anaconda terminal/ cmd

for example:

C:UsersUSER->cd desktop "if you downloaded the file to your desktop" this command will move you to the current directory of the .whl file

then input: "pip install dlib-19.22.99-cp39-cp39-win_amd64.whl"

that should work…hopefully

Answered By: tobii
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.