无法在 Win10 上使用 pip install face_recognition 安装 face_recognition

Cannot install face_recognition using pip install face_recognition on Win10

我收到错误

运行 setup.py 安装 dlib ... 错误 错误:子进程因错误而退出

× 运行 setup.py dlib 安装没有 运行 成功。 │ 退出代码:1 ╰─>【58行输出】 运行正在安装 运行宁建 运行宁build_py 未找到包初始化文件 'tools\python\dlib_init_.py'(或不是常规文件) 运行宁build_ext Python 3.10.4 的构建扩展(tags/v3.10.4:9d38120,2022 年 3 月 23 日,23:13:41)[MSC v.1929 64 位 (AMD64)] 调用 CMake 设置:'cmake C:\Users\amade\AppData\Local\Temp\pip-install-_k5e982w\dlib_237006073dfd4b13993bf60b7ecb3629\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\amade\AppData\Local\Temp\pip-install-_k5e982w\dlib_237006073dfd4b13993bf60b7ecb3629\build\lib.win-amd64-3.10 -DPYTHON_EXECUTABLE=C:\Users\amade\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\amade\AppData\Local\Temp\pip-install-_k5e982w\dlib_237006073dfd4b13993bf60b7ecb3629\build\lib.win-amd64-3.10 -A x64' -- 建设时间:Visual Studio 17 2022 -- 选择 Windows SDK 版本以 Windows 10.0.19044 为目标。 -- C 编译器标识未知 -- CXX 编译器标识未知 CMakeLists.txt:14 处的 CMake 错误(项目): 找不到 CMAKE_C_COMPILER。

  CMake Error at CMakeLists.txt:14 (project):
    No CMAKE_CXX_COMPILER could be found.



  -- Configuring incomplete, errors occurred!
  See also "C:/Users/amade/AppData/Local/Temp/pip-install-_k5e982w/dlib_237006073dfd4b13993bf60b7ecb3629/build/temp.win-amd64-3.10/Release/CMakeFiles/CMakeOutput.log".
  See also "C:/Users/amade/AppData/Local/Temp/pip-install-_k5e982w/dlib_237006073dfd4b13993bf60b7ecb3629/build/temp.win-amd64-3.10/Release/CMakeFiles/CMakeError.log".
  Traceback (most recent call last):
    File "<string>", line 2, in <module>
    File "<pip-setuptools-caller>", line 34, in <module>
    File "C:\Users\amade\AppData\Local\Temp\pip-install-_k5e982w\dlib_237006073dfd4b13993bf60b7ecb3629\setup.py", line 222, in <module>
      setup(
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0\lib\site-packages\setuptools\__init__.py", line 153, in setup
      return distutils.core.setup(**attrs)
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0\lib\distutils\core.py", line 148, in setup
      dist.run_commands()
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0\lib\distutils\dist.py", line 966, in run_commands
      self.run_command(cmd)
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0\lib\distutils\dist.py", line 985, in run_command
      cmd_obj.run()
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0\lib\site-packages\setuptools\command\install.py", line 61, in run
      return orig.install.run(self)
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0\lib\distutils\command\install.py", line 568, in run
      self.run_command('build')
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.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.10_3.10.1264.0_x64__qbz5n2kfra8p0\lib\distutils\dist.py", line 985, in run_command
      cmd_obj.run()
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.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.10_3.10.1264.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.10_3.10.1264.0_x64__qbz5n2kfra8p0\lib\distutils\dist.py", line 985, in run_command
      cmd_obj.run()
    File "C:\Users\amade\AppData\Local\Temp\pip-install-_k5e982w\dlib_237006073dfd4b13993bf60b7ecb3629\setup.py", line 134, in run
      self.build_extension(ext)
    File "C:\Users\amade\AppData\Local\Temp\pip-install-_k5e982w\dlib_237006073dfd4b13993bf60b7ecb3629\setup.py", line 171, in build_extension
      subprocess.check_call(cmake_setup, cwd=build_folder)
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 369, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['cmake', 'C:\Users\amade\AppData\Local\Temp\pip-install-_k5e982w\dlib_237006073dfd4b13993bf60b7ecb3629\tools\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\amade\AppData\Local\Temp\pip-install-_k5e982w\dlib_237006073dfd4b13993bf60b7ecb3629\build\lib.win-amd64-3.10', '-DPYTHON_EXECUTABLE=C:\Users\amade\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\amade\AppData\Local\Temp\pip-install-_k5e982w\dlib_237006073dfd4b13993bf60b7ecb3629\build\lib.win-amd64-3.10', '-A', 'x64']' returned non-zero exit status 1.
  [end of output]

注意:此错误源自子进程,可能不是 pip 的问题。 错误:遗留安装失败

× 尝试安装包时遇到错误。 ╰─> dlib

注意:这是上面提到的包的问题,​​不是pip。 提示:有关失败的输出,请参见上文。

按照以下步骤在 Windows 10.

上安装 face_recognition python 包

指令已在 Windows 10 64bit, python 3.9.

上测试

第 1 步

official site

为您的OS下载CMake安装包

第 2 步

安装下载的CMake安装包。请确保在安装过程中选择了 Add CMake to system PATH 选项。

步骤 3

重新启动您的 OS(重新启动计算机)

第 4 步

运行 pip install dlib 这需要几分钟,所以请做好等待的准备

第 5 步

如果它完成且没有任何错误,则一切就绪。 运行 pip install face_recognition 安装 face_recognition.

结果

已修复。我不得不从“开始”菜单程序修改我的 Visual Studio 安装,并包含最新的 MSVC 并在 Individual Components

下包含 Windows 10 SDK