24

I have already installed CMake by pip install cmake and tried to install face_recognition but it still gives me a RuntimeError. I'm using 'Python 3.7.3, x32'

I also tried to install the dlib by pip install dlib since it is one of the reasons why I can't install face_recognition.

C:\Users\user>python -m pip install cmake
Requirement already satisfied: cmake in c:\users\user\appdata\roaming\python\python37\site-packages (3.14.4)

C:\Users\user>python -m pip install dlib
Collecting dlib
  Using cached https://files.pythonhosted.org/packages/05/57/e8a8caa3c89a27f80bc78da39c423e2553f482a3705adc619176a3a24b36/dlib-19.17.0.tar.gz
Installing collected packages: dlib
  Running setup.py install for dlib ... error
    ERROR: Complete output from command 'C:\Python\Python37\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-24vk6act\\dlib\\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\user\AppData\Local\Temp\pip-record-yf2kdjpx\install-record.txt' --single-version-externally-managed --compile:
    ERROR: running install
    running build
    running build_py
    package init file 'dlib\__init__.py' not found (or not a regular file)
    running build_ext
    Traceback (most recent call last):
      File "C:\Users\user\AppData\Local\Temp\pip-install-24vk6act\dlib\setup.py", line 120, in get_cmake_version
        out = subprocess.check_output(['cmake', '--version'])
      File "C:\Python\Python37\lib\subprocess.py", line 395, in check_output
        **kwargs).stdout
      File "C:\Python\Python37\lib\subprocess.py", line 472, in run
        with Popen(*popenargs, **kwargs) as process:
      File "C:\Python\Python37\lib\subprocess.py", line 775, in __init__
        restore_signals, start_new_session)
      File "C:\Python\Python37\lib\subprocess.py", line 1178, in _execute_child
        startupinfo)
    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:\Users\user\AppData\Local\Temp\pip-install-24vk6act\dlib\setup.py", line 261, in <module>
        'Topic :: Software Development',
      File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\setuptools\__init__.py", line 145, in setup
        return distutils.core.setup(**attrs)
      File "C:\Python\Python37\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "C:\Python\Python37\lib\distutils\dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "C:\Python\Python37\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\setuptools\command\install.py", line 61, in run
        return orig.install.run(self)
      File "C:\Python\Python37\lib\distutils\command\install.py", line 545, in run
        self.run_command('build')
      File "C:\Python\Python37\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:\Python\Python37\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\Python\Python37\lib\distutils\command\build.py", line 135, in run
        self.run_command(cmd_name)
      File "C:\Python\Python37\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:\Python\Python37\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\Users\user\AppData\Local\Temp\pip-install-24vk6act\dlib\setup.py", line 129, in run
        cmake_version = self.get_cmake_version()
      File "C:\Users\user\AppData\Local\Temp\pip-install-24vk6act\dlib\setup.py", line 125, in get_cmake_version
        "\n*******************************************************************\n")
    RuntimeError:
    *******************************************************************
     CMake must be installed to build the following extensions: dlib
    *******************************************************************

    ----------------------------------------
ERROR: Command "'C:\Python\Python37\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-24vk6act\\dlib\\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\user\AppData\Local\Temp\pip-record-yf2kdjpx\install-record.txt' --single-version-externally-managed --compile" failed with error code 1 in C:\Users\user\AppData\Local\Temp\pip-install-24vk6act\dlib\
Smart Manoj
  • 5,230
  • 4
  • 34
  • 59
Jomar Gallano
  • 261
  • 1
  • 2
  • 4

4 Answers4

28

Download and install dlib wheel from here

Then pip install face_recognition


  • pip install cmake
  • In visual studio, Individual Components tab,Visual C++ tools for Cmake checkbox under Compilers,build tools and runtimes Section
  • On Visual Studio Command prompt run, pip install face_recognition

Source

Smart Manoj
  • 5,230
  • 4
  • 34
  • 59
  • do i have to install visual studio 2019 or any other version? even though i am just using visual studio code alone? – Jomar Gallano Jul 03 '19 at 03:05
  • Or try the dlib wheel – Smart Manoj Jul 03 '19 at 05:45
  • No need to install VSCode. I used create python virtual environment version 3.6 and installed `dlib` with wheel file as it was supporting upto version 3.6. Then did `pip install cmake` & then `pip install face_recognition`. – Mohith7548 Dec 12 '20 at 17:25
12

What works for is ... After getting lots of Red Errors, I run following

  1. conda install -c conda-forge dlib
  2. pip install cmake
  3. pip install face_recognition

Even the error says me to reinstall VS Code for c++. but above sequential installation works.

Python version was 3.8
SUBHABRATA NATH
  • 125
  • 1
  • 6
2

Try install dlib using conda conda install -c conda-forge dlib

  • Please provide other alternate installation methods using other package managers. – psyFi Feb 21 '21 at 05:53
  • This has worked for me. Firstly you need to have a visual studio installer where you install CMake and other Microsoft build tools and then just by following the above command you can install dlib and then face recognition library – nitesh mishra Apr 10 '21 at 09:53
0

For me, non of the solutions didn't work. Then, I downloaded all libraries in face_recognition package manually (like "pip install dlib==19.7", "pip install Click". At last, I installed face recognition with this command "pip install --no-deps face_recognition"

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 18 '22 at 08:22