繁体   English   中英

在 windows 10/11 上安装(python 库)face_recognition 时出现问题

[英]problem in Installing (python Library) face_recognition on windows 10/11

我正在使用 python 3.9.9 pip 21.3.1

我正在尝试安装 face_recognition

所以我安装了 CMake 然后当我尝试使用命令pip install dlib时,我得到了以下信息

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

    aring metadata (setup.py) ... done
    Building wheels for collected packag

es: dlib
  Building wheel for dlib (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'C:\Users\aenas\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\aenas\\AppData\\Local\\Temp\\pip-install-78dld3fg\\dlib_098968d181654cc09e283aff4801a4b1\\setup.py'"'"'; __file__='"'"'C:\\Users\\aenas\\AppData\\Local\\Temp\\pip-install-78dld3fg\\dlib_098968d181654cc09e283aff4801a4b1\\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'"'"'))' bdist_wheel -d 'C:\Users\aenas\AppData\Local\Temp\pip-wheel-hjnpx8xk'
       cwd: C:\Users\aenas\AppData\Local\Temp\pip-install-78dld3fg\dlib_098968d181654cc09e283aff4801a4b1\
  Complete output (8 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

  ERROR: CMake must be installed to build dlib

  ----------------------------------------
  ERROR: Failed building wheel for dlib
  Running setup.py clean for dlib
Failed to build dlib
Installing collected packages: dlib
    Running setup.py install for dlib ... error
    ERROR: Command errored out with exit status 1:
     command: 'C:\Users\aenas\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\aenas\\AppData\\Local\\Temp\\pip-install-78dld3fg\\dlib_098968d181654cc09e283aff4801a4b1\\setup.py'"'"'; __file__='"'"'C:\\Users\\aenas\\AppData\\Local\\Temp\\pip-install-78dld3fg\\dlib_098968d181654cc09e283aff4801a4b1\\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\aenas\AppData\Local\Temp\pip-record-zbjc8ulw\install-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:\Users\aenas\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Include\dlib'
         cwd: C:\Users\aenas\AppData\Local\Temp\pip-install-78dld3fg\dlib_098968d181654cc09e283aff4801a4b1\
    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

    ----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\aenas\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\aenas\\AppData\\Local\\Temp\\pip-install-78dld3fg\\dlib_098968d181654cc09e283aff4801a4b1\\setup.py'"'"'; __file__='"'"'C:\\Users\\aenas\\AppData\\Local\\Temp\\pip-install-78dld3fg\\dlib_098968d181654cc09e283aff4801a4b1\\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\aenas\AppData\Local\Temp\pip-record-zbjc8ulw\install-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:\Users\aenas\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Include\dlib' Check the logs for full command output.**

当我尝试使用命令pip install face_recognition ,我得到以下信息:

Collecting face_recognition
  Using cached face_recognition-1.3.0-py2.py3-none-any.whl (15 kB)
Requirement already satisfied: face-recognition-models>=0.3.0 in c:\users\aenas\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from face_recognition) (0.3.0)
Collecting dlib>=19.7
  Using cached dlib-19.22.1.tar.gz (7.4 MB)
  Preparing metadata (setup.py) ... done
Collecting Click>=6.0
  Using cached click-8.0.3-py3-none-any.whl (97 kB)
Requirement already satisfied: numpy in c:\users\aenas\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from face_recognition) (1.21.4)
Requirement already satisfied: Pillow in c:\users\aenas\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from face_recognition) (8.4.0)
Requirement already satisfied: colorama in c:\users\aenas\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from Click>=6.0->face_recognition) (0.4.4)
Building wheels for collected packages: dlib
  Building wheel for dlib (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'C:\Users\aenas\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\aenas\\AppData\\Local\\Temp\\pip-install-cy9bzkon\\dlib_8e45a10b6067402ab676a29d5bd742c8\\setup.py'"'"'; __file__='"'"'C:\\Users\\aenas\\AppData\\Local\\Temp\\pip-install-cy9bzkon\\dlib_8e45a10b6067402ab676a29d5bd742c8\\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'"'"'))' bdist_wheel -d 'C:\Users\aenas\AppData\Local\Temp\pip-wheel-elyfs9nv'
       cwd: C:\Users\aenas\AppData\Local\Temp\pip-install-cy9bzkon\dlib_8e45a10b6067402ab676a29d5bd742c8\
  Complete output (8 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

  ERROR: CMake must be installed to build dlib

  ----------------------------------------
  ERROR: Failed building wheel for dlib
  Running setup.py clean for dlib
Failed to build dlib
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\aenas\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\aenas\\AppData\\Local\\Temp\\pip-install-cy9bzkon\\dlib_8e45a10b6067402ab676a29d5bd742c8\\setup.py'"'"'; __file__='"'"'C:\\Users\\aenas\\AppData\\Local\\Temp\\pip-install-cy9bzkon\\dlib_8e45a10b6067402ab676a29d5bd742c8\\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\aenas\AppData\Local\Temp\pip-record-oojov4ij\install-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:\Users\aenas\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Include\dlib'
         cwd: C:\Users\aenas\AppData\Local\Temp\pip-install-cy9bzkon\dlib_8e45a10b6067402ab676a29d5bd742c8\
    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

    ----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\aenas\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\aenas\\AppData\\Local\\Temp\\pip-install-cy9bzkon\\dlib_8e45a10b6067402ab676a29d5bd742c8\\setup.py'"'"'; __file__='"'"'C:\\Users\\aenas\\AppData\\Local\\Temp\\pip-install-cy9bzkon\\dlib_8e45a10b6067402ab676a29d5bd742c8\\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\aenas\AppData\Local\Temp\pip-record-oojov4ij\install-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:\Users\aenas\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Include\dlib' Check the logs for full command output.

虽然我尝试了很多解决方案,但没有一个能解决我的问题

幸运的是,我解决了这个问题。 这些是下载 face_recognition 库的步骤:

1-安装 python:

在命令提示符下输入python并点击回车,这会为你打开微软商店,点击下载或安装即可下载并安装 python。 “检查它是否已下载,在命令提示符下键入python

2-安装 pip 如果你没有它:

go 到: https://pypi.org/project/pip-download/点击下载文件。 现在打开下载的文件,然后用鼠标右键单击并选择“在windows终端中打开”。 现在输入命令python get-pip.py 现在您的 pip 应该已安装,在终端中键入pip以检查它是否已安装

3-为 C++ 安装 Visual Studio 工具

go 至: https://visualstudio.microsoft.com/并下载 VS 社区版。 下载后安装并在安装页面选择以下选项:
图片1 图片2

并选择安装

4-安装cmake

输入命令pip install cmake并等待安装。

5-将 cmake 添加到路径变量

按照以下链接中的说明了解如何向 Path 变量添加内容: https://helpdeskgeek.com/windows-10/add-windows-path-environment-variable/

6-安装dlib

在命令提示符下写入以下命令: pip install dlib

7-安装人脸识别

在命令提示符下写入以下命令: pip install face_recognition

8- 在 PyCharm 中启动您的项目

单击文件单击搜索类型“解释器”中的“座位”选择“python解释器”选择“显示全部”单击“+”号选择系统解释器选择其路径以“用户”目录开头的解释器

那是我用来解决问题的解决方案

对于第 5 步,您在创建新路径变量的文本框中究竟输入了什么? 谢谢!!

完成所有描述的步骤后,我仍然收到以下错误:
任何帮助都将不胜感激!

Collecting dlib 
  Using cached dlib-19.24.0.tar.gz (3.2 MB) 
  Preparing metadata (setup.py) ... done 

Installing collected packages: dlib
  DEPRECATION: dlib is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559
  Running setup.py install for dlib ... error
  error: subprocess-exited-with-error

  × Running setup.py install for dlib did not run successfully.
  │ exit code: 1
  ╰─> [9 lines of output]
      running install
      C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      running build_ext

      ERROR: CMake must be installed to build dlib

      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> dlib

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM