Wednesday, December 29, 2021

Error during install face recognition openCV library

Try to install face-recognition

>> 1. pip install face-recognition

The following error occurs

    ERROR: Command errored out with exit status 1:

     command: 'C:\Users\user1\AppData\Local\Programs\Python\Python310\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\user1\\AppData\\Local\\Temp\\pip-install-8aq3akpy\\dlib_948d0b43c95149f1b66c47d668a43117\\setup.py'"'"'; __file__='"'"'C:\\Users\\user1\\AppData\\Local\\Temp\\pip-install-8aq3akpy\\dlib_948d0b43c95149f1b66c47d668a43117\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\user1\AppData\Local\Temp\pip-record-icdraszt\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\user1\AppData\Local\Programs\Python\Python310\Include\dlib'

         cwd: C:\Users\user1\AppData\Local\Temp\pip-install-8aq3akpy\dlib_948d0b43c95149f1b66c47d668a43117\

    Complete output (8 lines):

    running install

    running build

    running build_py

    package init file 'tools\python\dlib\__init__.py' not found (or not a regular file)

    running build_ext

    ERROR: CMake must be installed to build dlib


-------------------------------------------------------------------------------------------

Install cmake first and retry to install face-recognition

>> 1. pip install cmake

Result okay.

>> 2. pip install face-recognition

Another error occurs

Collecting face-recognition

  Using cached face_recognition-1.3.0-py2.py3-none-any.whl (15 kB)

Collecting Click>=6.0

  Using cached click-8.0.3-py3-none-any.whl (97 kB)

Collecting dlib>=19.7

  Using cached dlib-19.22.1.tar.gz (7.4 MB)

  Preparing metadata (setup.py) ... done

Requirement already satisfied: Pillow in c:\users\user1\appdata\local\programs\python\python310\lib\site-packages (from face-recognition) (8.4.0)

Requirement already satisfied: face-recognition-models>=0.3.0 in c:\users\user1\appdata\local\programs\python\python310\lib\site-packages (from face-recognition) (0.3.0)

Requirement already satisfied: numpy in c:\users\user1\appdata\local\programs\python\python310\lib\site-packages (from face-recognition) (1.21.5)

Requirement already satisfied: colorama in c:\users\user1\appdata\local\programs\python\python310\lib\site-packages (from Click>=6.0->face-recognition) (0.4.4)

Using legacy 'setup.py install' for dlib, since package 'wheel' is not installed.

Installing collected packages: dlib, Click, face-recognition

    Running setup.py install for dlib ... error

    ERROR: Command errored out with exit status 1:

     command: 'C:\Users\user1\AppData\Local\Programs\Python\Python310\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\user1\\AppData\\Local\\Temp\\pip-install-irtsarfs\\dlib_286f31435cee4d82a3d5891795f64bb6\\setup.py'"'"'; __file__='"'"'C:\\Users\\user1\\AppData\\Local\\Temp\\pip-install-irtsarfs\\dlib_286f31435cee4d82a3d5891795f64bb6\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\user1\AppData\Local\Temp\pip-record-lp8e89mp\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\user1\AppData\Local\Programs\Python\Python310\Include\dlib'

         cwd: C:\Users\user1\AppData\Local\Temp\pip-install-irtsarfs\dlib_286f31435cee4d82a3d5891795f64bb6\

    Complete output (60 lines):

    running install

    running build

    running build_py

    package init file 'tools\python\dlib\__init__.py' not found (or not a regular file)

    running build_ext

    Building extension for Python 3.10.1 (tags/v3.10.1:2cd268a, Dec  6 2021, 19:10:37) [MSC v.1929 64 bit (AMD64)]

    Invoking CMake setup: 'cmake C:\Users\user1\AppData\Local\Temp\pip-install-irtsarfs\dlib_286f31435cee4d82a3d5891795f64bb6\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\user1\AppData\Local\Temp\pip-install-irtsarfs\dlib_286f31435cee4d82a3d5891795f64bb6\build\lib.win-amd64-3.10 -DPYTHON_EXECUTABLE=C:\Users\user1\AppData\Local\Programs\Python\Python310\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\user1\AppData\Local\Temp\pip-install-irtsarfs\dlib_286f31435cee4d82a3d5891795f64bb6\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 1, in <module>

      File "C:\Users\user1\AppData\Local\Temp\pip-install-irtsarfs\dlib_286f31435cee4d82a3d5891795f64bb6\setup.py", line 222, in <module>

        setup(

      File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\__init__.py", line 153, in setup

        return distutils.core.setup(**attrs)

      File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\distutils\core.py", line 148, in setup

        dist.run_commands()

      File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\distutils\dist.py", line 966, in run_commands

        self.run_command(cmd)

      File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\distutils\dist.py", line 985, in run_command

        cmd_obj.run()

      File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\command\install.py", line 61, in run

        return orig.install.run(self)

      File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\distutils\command\install.py", line 568, in run

        self.run_command('build')

      File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\distutils\cmd.py", line 313, in run_command

        self.distribution.run_command(command)

      File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\distutils\dist.py", line 985, in run_command

        cmd_obj.run()

      File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\distutils\command\build.py", line 135, in run

        self.run_command(cmd_name)

      File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\distutils\cmd.py", line 313, in run_command

        self.distribution.run_command(command)

      File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\distutils\dist.py", line 985, in run_command

        cmd_obj.run()

      File "C:\Users\user1\AppData\Local\Temp\pip-install-irtsarfs\dlib_286f31435cee4d82a3d5891795f64bb6\setup.py", line 134, in run

        self.build_extension(ext)

      File "C:\Users\user1\AppData\Local\Temp\pip-install-irtsarfs\dlib_286f31435cee4d82a3d5891795f64bb6\setup.py", line 171, in build_extension

        subprocess.check_call(cmake_setup, cwd=build_folder)

      File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 369, in check_call

        raise CalledProcessError(retcode, cmd)

    subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\user1\\AppData\\Local\\Temp\\pip-install-irtsarfs\\dlib_286f31435cee4d82a3d5891795f64bb6\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\user1\\AppData\\Local\\Temp\\pip-install-irtsarfs\\dlib_286f31435cee4d82a3d5891795f64bb6\\build\\lib.win-amd64-3.10', '-DPYTHON_EXECUTABLE=C:\\Users\\user1\\AppData\\Local\\Programs\\Python\\Python310\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\user1\\AppData\\Local\\Temp\\pip-install-irtsarfs\\dlib_286f31435cee4d82a3d5891795f64bb6\\build\\lib.win-amd64-3.10', '-A', 'x64']' returned non-zero exit status 1.

    ----------------------------------------

ERROR: Command errored out with exit status 1: 'C:\Users\user1\AppData\Local\Programs\Python\Python310\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\user1\\AppData\\Local\\Temp\\pip-install-irtsarfs\\dlib_286f31435cee4d82a3d5891795f64bb6\\setup.py'"'"'; __file__='"'"'C:\\Users\\user1\\AppData\\Local\\Temp\\pip-install-irtsarfs\\dlib_286f31435cee4d82a3d5891795f64bb6\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\user1\AppData\Local\Temp\pip-record-lp8e89mp\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\user1\AppData\Local\Programs\Python\Python310\Include\dlib' Check the logs for full command output.

----------------------------------

Install visual studio for C++ and try again.