Erfan Kamali
Erfan Kamali

Reputation: 1

Error in installing face-recognition library

When installing face-recognition in Windows I'm getting the following traceback:

C:\Windows\system32>pip install face-recognition
Collecting face-recognition
  Using cached https://files.pythonhosted.org/packages/3f/ed/ad9a28042f373d4633fc8b49109b623597d6f193d3bbbef7780a5ee8eef2/face_recognition-1.2.3-py2.py3-none-any.whl
Requirement already satisfied: numpy in c:\program files\python37\lib\site-packages (from face-recognition) (1.16.4)
Requirement already satisfied: Click>=6.0 in c:\program files\python37\lib\site-packages (from face-recognition) (7.0)
Collecting dlib>=19.7 (from face-recognition)
  Using cached https://files.pythonhosted.org/packages/05/57/e8a8caa3c89a27f80bc78da39c423e2553f482a3705adc619176a3a24b36/dlib-19.17.0.tar.gz
Requirement already satisfied: Pillow in c:\program files\python37\lib\site-packages (from face-recognition) (6.0.0)
Requirement already satisfied: face-recognition-models>=0.3.0 in c:\program files\python37\lib\site-packages (from face-recognition) (0.3.0)
Installing collected packages: dlib, face-recognition
  Running setup.py install for dlib ... error
    ERROR: Command errored out with exit status 1:
     command: 'c:\program files\python37\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Erfan\\AppData\\Local\\Temp\\pip-install-kkt88o4h\\dlib\\setup.py'"'"'; __file__='"'"'C:\\Users\\Erfan\\AppData\\Local\\Temp\\pip-install-kkt88o4h\\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\Erfan\AppData\Local\Temp\pip-record-7hhzklek\install-record.txt' --single-version-externally-managed --compile
         cwd: C:\Users\Erfan\AppData\Local\Temp\pip-install-kkt88o4h\dlib\
    Complete output (57 lines):
    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:\Users\Erfan\AppData\Local\Temp\pip-install-kkt88o4h\dlib\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\Erfan\AppData\Local\Temp\pip-install-kkt88o4h\dlib\build\lib.win-amd64-3.7 -DPYTHON_EXECUTABLE=c:\program files\python37\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\Erfan\AppData\Local\Temp\pip-install-kkt88o4h\dlib\build\lib.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/Erfan/AppData/Local/Temp/pip-install-kkt88o4h/dlib/build/temp.win-amd64-3.7/Release/CMakeFiles/CMakeOutput.log".
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\Erfan\AppData\Local\Temp\pip-install-kkt88o4h\dlib\setup.py", line 261, in <module>
        'Topic :: Software Development',
      File "c:\program files\python37\lib\site-packages\setuptools\__init__.py", line 143, in setup
        return distutils.core.setup(**attrs)
      File "c:\program files\python37\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "c:\program files\python37\lib\distutils\dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "c:\program files\python37\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "c:\program files\python37\lib\site-packages\setuptools\command\install.py", line 61, in run
        return orig.install.run(self)
      File "c:\program files\python37\lib\distutils\command\install.py", line 545, in run
        self.run_command('build')
      File "c:\program files\python37\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "c:\program files\python37\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "c:\program files\python37\lib\distutils\command\build.py", line 135, in run
        self.run_command(cmd_name)
      File "c:\program files\python37\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "c:\program files\python37\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\Users\Erfan\AppData\Local\Temp\pip-install-kkt88o4h\dlib\setup.py", line 135, in run
        self.build_extension(ext)
      File "C:\Users\Erfan\AppData\Local\Temp\pip-install-kkt88o4h\dlib\setup.py", line 172, in build_extension
        subprocess.check_call(cmake_setup, cwd=build_folder)
      File "c:\program files\python37\lib\subprocess.py", line 347, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\Erfan\\AppData\\Local\\Temp\\pip-install-kkt88o4h\\dlib\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\Erfan\\AppData\\Local\\Temp\\pip-install-kkt88o4h\\dlib\\build\\lib.win-amd64-3.7', '-DPYTHON_EXECUTABLE=c:\\program files\\python37\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\Erfan\\AppData\\Local\\Temp\\pip-install-kkt88o4h\\dlib\\build\\lib.win-amd64-3.7', '-A', 'x64']' returned non-zero exit status 1.
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\program files\python37\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Erfan\\AppData\\Local\\Temp\\pip-install-kkt88o4h\\dlib\\setup.py'"'"'; __file__='"'"'C:\\Users\\Erfan\\AppData\\Local\\Temp\\pip-install-kkt88o4h\\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\Erfan\AppData\Local\Temp\pip-record-7hhzklek\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.

Upvotes: 0

Views: 1657

Answers (1)

Karthik
Karthik

Reputation: 73

Looks like you are getting the error when you are installing dlib which is a prerequisite for face recognition. Since you are trying to install it on windows, there are certain prerequisites which you must ensure. 1. You will need to download cmake and install it and ensure the path is set in your environment variables. 2. You will need to have VS 2015/2017 installed. I have not been able to get dlib working with VS2019 so far and I am not sure if it works well, hence use either 2015/2017. Then download dlib from their github link and manually build the library instead of doing pip install. Once dlib is installed you will then be able to install face-recognition using pip

Upvotes: 1

Related Questions