Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
308 views
in Technique[技术] by (71.8m points)

pip - Errors installing the module face_recognition in Python

I am having a huge error on installing face_recognition. I tried python -m pip install face_recognition in the terminal and I also tried pip3 install face_recognition as well as pip install face_recognition. I have no idea what to do and I am getting an error while building wheel for dlib (setup.py). This is the full thing:-

ERROR: Command errored out with exit status 1:
 command: 'C:UsersIamOmAppDataLocalMicrosoftWindowsAppsPythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\IamOm\AppData\Local\Temp\pip-install-ulht78ry\dlib_7953cb5ea1714420b8441816f930d73b\setup.py'"'"'; __file__='"'"'C:\Users\IamOm\AppData\Local\Temp\pip-install-ulht78ry\dlib_7953cb5ea1714420b8441816f930d73b\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'
'"'"', '"'"'
'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:UsersIamOmAppDataLocalTemppip-wheel-wiu22jp0'
       cwd: C:UsersIamOmAppDataLocalTemppip-install-ulht78rydlib_7953cb5ea1714420b8441816f930d73b
  Complete output (53 lines):
  running bdist_wheel
  running build
  running build_py
  package init file 'toolspythondlib\__init__.py' not found (or not a regular file)
  running build_ext
  Traceback (most recent call last):
    File "C:UsersIamOmAppDataLocalTemppip-install-ulht78rydlib_7953cb5ea1714420b8441816f930d73bsetup.py", line 120, in get_cmake_version
      out = subprocess.check_output(['cmake', '--version'])
    File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0libsubprocess.py", line 411, in check_output
      return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
    File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0libsubprocess.py", line 489, in run
      with Popen(*popenargs, **kwargs) as process:
    File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0libsubprocess.py", line 854, in __init__
      self._execute_child(args, executable, preexec_fn, close_fds,
    File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0libsubprocess.py", line 1307, in _execute_child
      hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
  FileNotFoundError: [WinError 2] The system cannot find the file specified

Next, I had another exception:-

Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:UsersIamOmAppDataLocalTemppip-install-ulht78rydlib_7953cb5ea1714420b8441816f930d73bsetup.py", line 223, in <module>
      setup(
    File "C:UsersIamOmAppDataLocalPackagesPythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0LocalCachelocal-packagesPython38site-packagessetuptools\__init__.py", line 163, in setup
      return distutils.core.setup(**attrs)
    File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0libdistutilscore.py", line 148, in setup
      dist.run_commands()
    File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0libdistutilsdist.py", line 966, in run_commands
      self.run_command(cmd)
    File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0libdistutilsdist.py", line 985, in run_command
      cmd_obj.run()
    File "C:UsersIamOmAppDataLocalPackagesPythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0LocalCachelocal-packagesPython38site-packageswheeldist_wheel.py", line 290, in run
      self.run_command('build')
    File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0libdistutilscmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0libdistutilsdist.py", line 985, in run_command
      cmd_obj.run()
    File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0libdistutilscommanduild.py", line 135, in run
      self.run_command(cmd_name)
    File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0libdistutilscmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0libdistutilsdist.py", line 985, in run_command
      cmd_obj.run()
    File "C:UsersIamOmAppDataLocalTemppip-install-ulht78rydlib_7953cb5ea1714420b8441816f930d73bsetup.py", line 129, in run
      cmake_version = self.get_cmake_version()
    File "C:UsersIamOmAppDataLocalTemppip-install-ulht78rydlib_7953cb5ea1714420b8441816f930d73bsetup.py", line 122, in get_cmake_version
      raise RuntimeError("
*******************************************************************
" +


    RuntimeError:

  *******************************************************************
   CMake must be installed to build the following extensions: _dlib_pybind11
  *******************************************************************

I already have CMake installed on my system without any errors, still I get this.


ERROR: Failed building wheel for dlib

Then it ran setup.py clean for dlib:- Running setup.py clean for dlib Failed to build dlib

Then it ran setup.py install for dlib:- Running setup.py install for dlib ... error

ERROR: Command errored out with exit status 1:
 command: 'C:UsersIamOmAppDataLocalMicrosoftWindowsAppsPythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\IamOm\AppData\Local\Temp\pip-install-ulht78ry\dlib_7953cb5ea1714420b8441816f930d73b\setup.py'"'"'; __file__='"'"'C:\Users\IamOm\AppData\Local\Temp\pip-install-ulht78ry\dlib_7953cb5ea1714420b8441816f930d73b\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'
'"'"', '"'"'
'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:UsersIamOmAppDataLocalTemppip-record-3tst66j8install-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:UsersIamOmAppDataLocalPackagesPythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0LocalCachelocal-packagesPython38Includedlib'
     cwd: C:UsersIamOmAppDataLocalTemppip-install-ulht78rydlib_7953cb5ea1714420b8441816f930d73b
Complete output (55 lines):
running install
running build
running build_py
package init file 'toolspythondlib\__init__.py' not found (or not a regular file)
running build_ext
Traceback (most recent call last):
  File "C:UsersIamOmAppDataLocalTemppip-install-ulht78rydlib_7953cb5ea1714420b8441816f930d73bsetup.py", line 120, in get_cmake_version
    out = subprocess.check_output(['cmake', '--version'])
  File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0libsubprocess.py", line 411, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0libsubprocess.py", line 489, in run
    with Popen(*popenargs, **kwargs) as process:
  File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0libsubprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0libsubprocess.py", line 1307, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

And then another exception:-

 During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:UsersIamOmAppDataLocalTemppip-install-ulht78rydlib_7953cb5ea1714420b8441816f930d73bsetup.py", line 223, in <module>
        setup(
      File "C:UsersIamOmAppDataLocalPackagesPythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0LocalCachelocal-packagesPython38site-packagessetuptools\__init__.py", line 163, in setup
        return distutils.core.setup(**attrs)
      File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0libdistutilscore.py", line 148, in setup
        dist.run_commands()
      File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0libdistutilsdist.py", line 966, in run_commands
        self.run_command(cmd)
      File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0libdistutilsdist.py", line 985, in run_command
        cmd_obj.run()
      File "C:UsersIamOmAppDataLocalPackagesPythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0LocalCachelocal-packagesPython38site-packagessetuptoolscommandinstall.py", line 61, in run
        return orig.install.run(self)
      File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0libdistutilscommandinstall.py", line 545, in run
        self.run_command('build')
      File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0libdistutilscmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0libdistutilsdist.py", line 985, in run_command
        cmd_obj.run()
      File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0libdistutilscommanduild.py", line 135, in run
        self.run_command(cmd_name)
      File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0libdistutilscmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0libdistutilsdist.py", line 985, in run_command
        cmd_obj.run()
      File "C:UsersIamOmAppDataLocalTemppip-install-ulht78rydlib_7953cb5ea1714420b8441816f930d73bsetup.py", line 129, in run
        cmake_version = self.get_cmake_version()
      File "C:UsersIamOmAppDataLocalTemppip-install-ulht78rydlib_7953cb5ea1714420b8441816f930d73bsetup.py", line 122, in get_cmake_version
        raise RuntimeError("
*******************************************************************
" +
    RuntimeError:
    *******************************************************************
     CMake must be installed to build the following extensions: _dlib_pybind11
    *******************************************************************

    ----------------------------------------
ERROR: Command errored out with exit status 1: 'C:UsersIa

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Here are some steps to install face_recognition in windows.

  1. Install Anaconda3 for windows
  2. Create an environment with python3.6
  3. Install Microsoft Visual Studio 2017 or Upgrade (C++ packages includes c++/CLI must be installed for CMake)
  4. Update Visual Sutudio 2017
  5. Reboot the Computer
  6. Download CMake (https://cmake.org/download/) and Install it
  7. Activate specific of Anaconda3 in the 'cmd'
  8. pip3 install face_recognition
  • face_recognition and dlib are not fully installed in specific , but default anaconda env.

  • so you should to copy from

c:programdataanaconda3scriptsface_detection.exe

c:programdataanaconda3scriptsface_recognition.exe

to scripts

and

c:programdataanaconda3libsite-packagesdlib-19.15.0.dist-info*

c:programdataanaconda3libsite-packagesdlib.cp36-win_amd64.pyd

to Libsite-package

  1. Finally, run the code below for test
import cv2
import dlib
import face_recognition

detector = dlib.get_frontal_face_detector()
cap = cv2.VideoCapture(0)

while(True):
    ret, frame = cap.read()
    dets = face_recognition.face_locations(frame, model="cnn")
    print("face_recognition:",dets)

    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    dets = detector(gray, 1)
    
    for i, d in enumerate(dets):
        print("dlib: Left: {} Top: {} Right: {} Bottom: {}".format(
            d.left(), d.top(), d.right(), d.bottom()))

    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

How to use GPU (Cuda) for DLib

  1. Download dlib-XX.XX.zip in the dlib site (http://dlib.net/)

  2. Activate in 'cmd' as administrator

  3. python setup.py install --yes USE_AVX_INSTRUCTIONS --yes DLIB_USE_CUDA

    if not working, try below

python setup.py install --yes USE_AVX_INSTRUCTIONS --clean


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...