我已经通过 pip install Cmake 安装了 Cmake,以及 Wheel 和 numpy。
尝试使用 pip install dlib 安装 dlib 时出现错误:
PS G:\WORK\EncroFace> pip install dlib --verbose
Using pip 24.0 from G:\WORK\EncroFace\venv\Lib\site-packages\pip (python 3.12)
Collecting dlib
Using cached dlib-19.24.4.tar.gz (3.3 MB)
Running command pip subprocess to install build dependencies
Collecting setuptools
Using cached setuptools-69.2.0-py3-none-any.whl.metadata (6.3 kB)
Collecting wheel
Using cached wheel-0.43.0-py3-none-any.whl.metadata (2.2 kB)
Using cached setuptools-69.2.0-py3-none-any.whl (821 kB)
Using cached wheel-0.43.0-py3-none-any.whl (65 kB)
Installing collected packages: wheel, setuptools
Successfully installed setuptools-69.2.0 wheel-0.43.0
Installing build dependencies ... done
Running command Getting requirements to build wheel
<string>:210: SyntaxWarning: invalid escape sequence '\('
<string>:211: SyntaxWarning: invalid escape sequence '\('
<string>:212: SyntaxWarning: invalid escape sequence '\('
running egg_info
writing tools/python\dlib.egg-info\PKG-INFO
writing dependency_links to tools/python\dlib.egg-info\dependency_links.txt
writing top-level names to tools/python\dlib.egg-info\top_level.txt
reading manifest file 'tools/python\dlib.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching 'tools\python\build*'
no previously-included directories found matching 'dlib\cmake_utils\*\build*'
no previously-included directories found matching 'dlib\test'
warning: no previously-included files matching '*.pyc' found anywhere in distribution
adding license file 'LICENSE.txt'
writing manifest file 'tools/python\dlib.egg-info\SOURCES.txt'
Getting requirements to build wheel ... done
Running command Preparing metadata (pyproject.toml)
<string>:210: SyntaxWarning: invalid escape sequence '\('
<string>:211: SyntaxWarning: invalid escape sequence '\('
<string>:212: SyntaxWarning: invalid escape sequence '\('
running dist_info
creating C:\Users\benjamin\AppData\Local\Temp\pip-modern-metadata-oiqzlulr\dlib.egg-info
writing C:\Users\benjamin\AppData\Local\Temp\pip-modern-metadata-oiqzlulr\dlib.egg-info\PKG-INFO
writing dependency_links to C:\Users\benjamin\AppData\Local\Temp\pip-modern-metadata-oiqzlulr\dlib.egg-info\dependency_links.txt
writing top-level names to C:\Users\benjamin\AppData\Local\Temp\pip-modern-metadata-oiqzlulr\dlib.egg-info\top_level.txt
writing manifest file 'C:\Users\benjamin\AppData\Local\Temp\pip-modern-metadata-oiqzlulr\dlib.egg-info\SOURCES.txt'
reading manifest file 'C:\Users\benjamin\AppData\Local\Temp\pip-modern-metadata-oiqzlulr\dlib.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching 'tools\python\build*'
no previously-included directories found matching 'dlib\cmake_utils\*\build*'
no previously-included directories found matching 'dlib\test'
warning: no previously-included files matching '*.pyc' found anywhere in distribution
adding license file 'LICENSE.txt'
writing manifest file 'C:\Users\benjamin\AppData\Local\Temp\pip-modern-metadata-oiqzlulr\dlib.egg-info\SOURCES.txt'
creating 'C:\Users\benjamin\AppData\Local\Temp\pip-modern-metadata-oiqzlulr\dlib-19.24.4.dist-info'
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: dlib
Running command Building wheel for dlib (pyproject.toml)
<string>:210: SyntaxWarning: invalid escape sequence '\('
<string>:211: SyntaxWarning: invalid escape sequence '\('
<string>:212: SyntaxWarning: invalid escape sequence '\('
running bdist_wheel
running build
running build_ext
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "G:\WORK\EncroFace\venv\Scripts\cmake.exe\__main__.py", line 4, in <module>
ModuleNotFoundError: No module named 'cmake'
ERROR: CMake must be installed to build dlib
error: subprocess-exited-with-error
× Building wheel for dlib (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
full command: 'G:\WORK\EncroFace\venv\Scripts\python.exe' 'G:\WORK\EncroFace\venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py' build_wheel 'C:\Users\benjamin\AppData\Local\Temp\tmpjicuj8sb'
cwd: C:\Users\benjamin\AppData\Local\Temp\pip-install-8curvry1\dlib_b75c506e5565413494e9496a676891ed
Building wheel for dlib (pyproject.toml) ... error
ERROR: Failed building wheel for dlib
Failed to build dlib
ERROR: Could not build wheels for dlib, which is required to install pyproject.toml-based projects
PS G:\WORK\EncroFace>
查看我的 venv 目录,我可以看到 cmake 文件已安装,我是否缺少另一个先决条件?网上的所有内容都说这应该有效。
我一直在 VScode 中工作,python 版本 3.12.2
我尝试直接从他们的网站安装 Cmake 并卸载并重新安装 python 模块。
当我点列表时它也会显示:
PS G:\WORK\EncroFace> pip list
Package Version
--------------- --------
build 1.2.1
cmake 3.29.0.1
colorama 0.4.6
numpy 1.26.4
packaging 24.0
pip 24.0
pyproject_hooks 1.0.0
setuptools 69.2.0
wheel 0.43.0
PS G:\WORK\EncroFace>
任何帮助将不胜感激。
首先使用 pip install cmake 在 venv 中安装 cmake
然后尝试使用二进制文件安装 dilb https://github.com/z-mahmud22/Dlib_Windows_Python3.x
找到适合您的Python版本的文件并按照安装指南进行操作 记得在执行命令之前将 whl 文件粘贴到项目文件夹中