簡體   English   中英

在 Python 中安裝模塊 face_recognition 時出錯

[英]Errors installing the module face_recognition in Python

我在安裝 face_recognition 時遇到了一個巨大的錯誤。 我在終端嘗試python -m pip install face_recognition我還嘗試pip3 install face_recognition以及pip install face_recognition 我不知道該怎么做,並且在為 dlib (setup.py) 構建輪子時遇到錯誤。 這是完整的事情:-

ERROR: Command errored out with exit status 1:
 command: 'C:\Users\IamOm\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\python.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('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\IamOm\AppData\Local\Temp\pip-wheel-wiu22jp0'
       cwd: C:\Users\IamOm\AppData\Local\Temp\pip-install-ulht78ry\dlib_7953cb5ea1714420b8441816f930d73b\
  Complete output (53 lines):
  running bdist_wheel
  running build
  running build_py
  package init file 'tools\python\dlib\__init__.py' not found (or not a regular file)
  running build_ext
  Traceback (most recent call last):
    File "C:\Users\IamOm\AppData\Local\Temp\pip-install-ulht78ry\dlib_7953cb5ea1714420b8441816f930d73b\setup.py", line 120, in get_cmake_version
      out = subprocess.check_output(['cmake', '--version'])
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 411, in check_output
      return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 489, in run
      with Popen(*popenargs, **kwargs) as process:
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 854, in __init__
      self._execute_child(args, executable, preexec_fn, close_fds,
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 1307, in _execute_child
      hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
  FileNotFoundError: [WinError 2] The system cannot find the file specified

接下來,我有另一個例外:-

Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\IamOm\AppData\Local\Temp\pip-install-ulht78ry\dlib_7953cb5ea1714420b8441816f930d73b\setup.py", line 223, in <module>
      setup(
    File "C:\Users\IamOm\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\setuptools\__init__.py", line 163, in setup
      return distutils.core.setup(**attrs)
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\distutils\core.py", line 148, in setup
      dist.run_commands()
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\distutils\dist.py", line 966, in run_commands
      self.run_command(cmd)
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\distutils\dist.py", line 985, in run_command
      cmd_obj.run()
    File "C:\Users\IamOm\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\wheel\bdist_wheel.py", line 290, in run
      self.run_command('build')
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\distutils\dist.py", line 985, in run_command
      cmd_obj.run()
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\distutils\command\build.py", line 135, in run
      self.run_command(cmd_name)
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\distutils\dist.py", line 985, in run_command
      cmd_obj.run()
    File "C:\Users\IamOm\AppData\Local\Temp\pip-install-ulht78ry\dlib_7953cb5ea1714420b8441816f930d73b\setup.py", line 129, in run
      cmake_version = self.get_cmake_version()
    File "C:\Users\IamOm\AppData\Local\Temp\pip-install-ulht78ry\dlib_7953cb5ea1714420b8441816f930d73b\setup.py", line 122, in get_cmake_version
      raise RuntimeError("\n*******************************************************************\n" +


    RuntimeError:

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

我已經在我的系統上安裝了 CMake,沒有任何錯誤,但我仍然得到了這個。


ERROR: Failed building wheel for dlib

然后它為 dlib 運行 setup.py clean:- 為 dlib 運行 setup.py clean 無法構建 dlib

然后它運行setup.py install for dlib :- Running setup.py install for dlib ...錯誤

ERROR: Command errored out with exit status 1:
 command: 'C:\Users\IamOm\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\python.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('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\IamOm\AppData\Local\Temp\pip-record-3tst66j8\install-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:\Users\IamOm\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\Include\dlib'
     cwd: C:\Users\IamOm\AppData\Local\Temp\pip-install-ulht78ry\dlib_7953cb5ea1714420b8441816f930d73b\
Complete output (55 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
Traceback (most recent call last):
  File "C:\Users\IamOm\AppData\Local\Temp\pip-install-ulht78ry\dlib_7953cb5ea1714420b8441816f930d73b\setup.py", line 120, in get_cmake_version
    out = subprocess.check_output(['cmake', '--version'])
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 411, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 489, in run
    with Popen(*popenargs, **kwargs) as process:
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 1307, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
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\IamOm\AppData\Local\Temp\pip-install-ulht78ry\dlib_7953cb5ea1714420b8441816f930d73b\setup.py", line 223, in <module>
        setup(
      File "C:\Users\IamOm\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\setuptools\__init__.py", line 163, in setup
        return distutils.core.setup(**attrs)
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\distutils\dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\Users\IamOm\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\setuptools\command\install.py", line 61, in run
        return orig.install.run(self)
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\distutils\command\install.py", line 545, in run
        self.run_command('build')
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\distutils\command\build.py", line 135, in run
        self.run_command(cmd_name)
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\Users\IamOm\AppData\Local\Temp\pip-install-ulht78ry\dlib_7953cb5ea1714420b8441816f930d73b\setup.py", line 129, in run
        cmake_version = self.get_cmake_version()
      File "C:\Users\IamOm\AppData\Local\Temp\pip-install-ulht78ry\dlib_7953cb5ea1714420b8441816f930d73b\setup.py", line 122, in get_cmake_version
        raise RuntimeError("\n*******************************************************************\n" +
    RuntimeError:
    *******************************************************************
     CMake must be installed to build the following extensions: _dlib_pybind11
    *******************************************************************

    ----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\IamOm\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\python.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('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\IamOm\AppData\Local\Temp\pip-record-3tst66j8\install-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:\Users\IamOm\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\Include\dlib' Check the logs for full command output.

請幫幫我。

首先,確保安裝 cmake。 然后,您可以從 Github 鏈接下載 dlib。 完成此操作后,您可以使用 pip(3) 安裝 face_recognition。

以下是在 windows 中安裝 face_recognition 的一些步驟。

  1. 為 windows 安裝Anaconda3
  2. 用python3.6創建環境
  3. 安裝 Microsoft Visual Studio 2017 或升級(C++ 包包括 c++/CLI 必須安裝 CMake)
  4. 更新 Visual Sutudio 2017
  5. 重新啟動計算機
  6. 下載 CMake ( https://cmake.org/download/ ) 並安裝
  7. 在“cmd”中激活特定的 Anaconda3
  8. pip3 安裝 face_recognition
  • face_recognition 和 dlib 沒有完全安裝,但默認 anaconda 環境。

  • 所以你應該從

c:\programdata\anaconda3\scripts\face_detection.exe

c:\programdata\anaconda3\scripts\face_recognition.exe

到\腳本\

c:\programdata\anaconda3\lib\site-packages\dlib-19.15.0.dist-info\*

c:\programdata\anaconda3\lib\site-packages\dlib.cp36-win_amd64.pyd

到 \Lib\site-package\

  1. 最后,運行下面的代碼進行測試
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

如何將 GPU (Cuda) 用於 DLib

  1. 在dlib站點下載dlib-XX.XX.zip ( http://dlib.net/ )

  2. 以管理員身份在“cmd”中激活

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

    如果不起作用,請嘗試以下

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM