我正在做一个需要人脸识别库的项目,需要dlib。
我在为项目安装“dlib”时遇到问题。终端抛出以下错误
error: subprocess-exited-with-error
× Building wheel for dlib (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [392 lines of output]
running bdist_wheel
running build
running build_ext
<string>:125: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
Building extension for Python 3.11.9 (tags/v3.11.9:de54cf5, Apr 2 2024, 10:12:12) [MSC v.1938 64 bit (AMD64)]
Invoking CMake setup: 'cmake C:\Users\LENOVO\AppData\Local\Temp\pip-install-n0wf3b9r\dlib_94f3ffa0c38b412abab68539f53bd7be\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\LENOVO\AppData\Local\Temp\pip-install-n0wf3b9r\dlib_94f3ffa0c38b412abab68539f53bd7be\build\lib.win-amd64-cpython-311 -DPYTHON_EXECUTABLE=C:\Users\LENOVO\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\LENOVO\AppData\Local\Temp\pip-install-n0wf3b9r\dlib_94f3ffa0c38b412abab68539f53bd7be\build\lib.win-amd64-cpython-311 -A x64'
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.22631.
-- The C compiler identification is MSVC 19.40.33811.0
-- The CXX compiler identification is MSVC 19.40.33811.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Deprecation Warning at C:/Users/LENOVO/AppData/Local/Temp/pip-install-n0wf3b9r/dlib_94f3ffa0c38b412abab68539f53bd7be/dlib/external/pybind11/CMakeLists.txt:8 (cmake_minimum_required):
Compatibility with CMake < 3.5 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
-- pybind11 v2.10.0
CMake Warning (dev) at C:/Users/LENOVO/AppData/Local/Temp/pip-install-n0wf3b9r/dlib_94f3ffa0c38b412abab68539f53bd7be/dlib/external/pybind11/tools/FindPythonLibsNew.cmake:98 (find_package):
Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules
are removed. Run "cmake --help-policy CMP0148" for policy details. Use
the cmake_policy command to set the policy and suppress this warning.
Call Stack (most recent call first):
C:/Users/LENOVO/AppData/Local/Temp/pip-install-n0wf3b9r/dlib_94f3ffa0c38b412abab68539f53bd7be/dlib/external/pybind11/tools/pybind11Tools.cmake:50 (find_package)
C:/Users/LENOVO/AppData/Local/Temp/pip-install-n0wf3b9r/dlib_94f3ffa0c38b412abab68539f53bd7be/dlib/external/pybind11/tools/pybind11Common.cmake:180 (include)
C:/Users/LENOVO/AppData/Local/Temp/pip-install-n0wf3b9r/dlib_94f3ffa0c38b412abab68539f53bd7be/dlib/external/pybind11/CMakeLists.txt:200 (include)
This warning is for project developers. Use -Wno-dev to suppress it.
-- Found PythonInterp: C:/Users/LENOVO/AppData/Local/Microsoft/WindowsApps/PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0/python.exe (found suitable version "3.11.9", minimum required is "3.6")
-- Found PythonLibs: C:/Program Files/WindowsApps/PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0/libs/python311.lib
-- Performing Test HAS_MSVC_GL_LTCG
-- Performing Test HAS_MSVC_GL_LTCG - Success
-- Using CMake version: 3.30.0-rc1
-- Compiling dlib version: 19.24.4
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of void*
-- Check size of void* - done
-- Enabling SSE2 instructions
-- Searching for JPEG XL
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
-- PkgConfig could not be found, JPEG XL support won't be available
-- Searching for BLAS and LAPACK
-- Searching for BLAS and LAPACK
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Found Threads: TRUE
CMake Warning (dev) at C:/Users/LENOVO/AppData/Local/Temp/pip-install-n0wf3b9r/dlib_94f3ffa0c38b412abab68539f53bd7be/dlib/CMakeLists.txt:652 (find_package):
Policy CMP0146 is not set: The FindCUDA module is removed. Run "cmake
--help-policy CMP0146" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.
This warning is for project developers. Use -Wno-dev to suppress it.
CUDA_TOOLKIT_ROOT_DIR not found or specified
-- Could NOT find CUDA (missing: CUDA_TOOLKIT_ROOT_DIR CUDA_NVCC_EXECUTABLE CUDA_INCLUDE_DIRS CUDA_CUDART_LIBRARY) (Required is at least version "7.5")
-- Found CUDA, but CMake was unable to find the cuBLAS libraries that should be part of every basic CUDA install. Your CUDA install is somehow broken or incomplete. Since cuBLAS is required for dlib to use CUDA we won't use CUDA.
-- DID NOT FIND CUDA
-- Disabling CUDA support for dlib. DLIB WILL NOT USE CUDA
-- Searching for FFMPEG/LIBAV
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
-- PkgConfig could not be found, FFMPEG won't be available
-- Configuring done (152.3s)
-- Generating done (0.2s)
-- Build files have been written to: C:/Users/LENOVO/AppData/Local/Temp/pip-install-n0wf3b9r/dlib_94f3ffa0c38b412abab68539f53bd7be/build/temp.win-amd64-cpython-311/Release
Invoking CMake build: 'cmake --build . --config Release -- /m'
MSBuild version 17.10.4+10fbfbf2e for .NET Framework
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(541,5): warning MSB8029: The Intermediate directory or Output directory cannot reside under the Temporary directory as it could lead to issues with incremental build. [C:\Users\LENOVO\AppData\Local\Temp\pip-install-n0wf3b9r\dlib_94f3ffa0c38b412abab68539f53bd7be\build\temp.win-amd64-cpython-311\Release\ZERO_CHECK.vcxproj]
1>Checking Build System
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(541,5): warning MSB8029: The Intermediate directory or Output directory cannot reside under the Temporary directory as it could lead to issues with incremental build. [C:\Users\LENOVO\AppData\Local\Temp\pip-install-n0wf3b9r\dlib_94f3ffa0c38b412abab68539f53bd7be\build\temp.win-amd64-cpython-311\Release\dlib_build\dlib.vcxproj]
Building Custom Rule C:/Users/LENOVO/AppData/Local/Temp/pip-install-n0wf3b9r/dlib_94f3ffa0c38b412abab68539f53bd7be/dlib/CMakeLists.txt
base64_kernel_1.cpp
bigint_kernel_1.cpp
bigint_kernel_2.cpp
bit_stream_kernel_1.cpp
entropy_decoder_kernel_1.cpp
entropy_decoder_kernel_2.cpp
entropy_encoder_kernel_1.cpp
entropy_encoder_kernel_2.cpp
md5_kernel_1.cpp
tokenizer_kernel_1.cpp
unicode.cpp
test_for_odr_violations.cpp
fft.cpp
sockets_kernel_1.cpp
bsp.cpp
dir_nav_kernel_1.cpp
dir_nav_kernel_2.cpp
dir_nav_extensions.cpp
fonts.cpp
linker_kernel_1.cpp
extra_logger_headers.cpp
logger_kernel_1.cpp
logger_config_file.cpp
misc_api_kernel_1.cpp
misc_api_kernel_2.cpp
sockets_extensions.cpp
sockets_kernel_2.cpp
sockstreambuf.cpp
sockstreambuf_unbuffered.cpp
server_kernel.cpp
server_iostream.cpp
server_http.cpp
multithreaded_object_extension.cpp
threaded_object_extension.cpp
threads_kernel_1.cpp
threads_kernel_2.cpp
threads_kernel_shared.cpp
thread_pool_extension.cpp
async.cpp
timer.cpp
stack_trace.cpp
cpu_dlib.cpp
tensor_tools.cpp
image_dataset_metadata.cpp
mnist.cpp
cifar.cpp
global_function_search.cpp
C:\Users\LENOVO\AppData\Local\Temp\pip-install-n0wf3b9r\dlib_94f3ffa0c38b412abab68539f53bd7be\dlib\geometry\rectangle.h(164,1): warning C4723: potential divide by 0 [C:\Users\LENOVO\AppData\Local\Temp\pip-install-n0wf3b9r\dlib_94f3ffa0c38b412abab68539f53bd7be\build\temp.win-amd64-cpython-311\Release\dlib_build\dlib.vcxproj]
kalman_filter.cpp
auto.cpp
widgets.cpp
drawable.cpp
canvas_drawing.cpp
style.cpp
base_widgets.cpp
gui_core_kernel_1.cpp
gui_core_kernel_2.cpp
png_loader.cpp
save_png.cpp
jpeg_loader.cpp
save_jpeg.cpp
arm_init.c
filter_neon_intrinsics.c
palette_neon_intrinsics.c
png.c
pngerror.c
pngget.c
pngmem.c
pngpread.c
pngread.c
pngrio.c
pngrtran.c
pngrutil.c
pngset.c
pngtrans.c
pngwio.c
pngwrite.c
pngwtran.c
pngwutil.c
adler32.c
compress.c
crc32.c
deflate.c
gzclose.c
gzlib.c
gzread.c
.
.
.
.
.
File "<string>", line 130, in run
File "<string>", line 170, in build_extension
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0\Lib\subprocess.py", line 413, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--config', 'Release', '--', '/m']' returned non-zero exit status 1.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
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
安装过程总是卡在“Buildingwheel for dlib(pyproject.toml)”上 5 分钟左右,然后抛出这个巨大的错误。我无法理解和理解错误的内容,但尝试了多种方法来解决它,但没有任何效果。
我尝试了网上找到的所有选项,例如创建虚拟环境、从github安装dlib的.exe文件、重新安装cmake,甚至尝试将python版本更改为3.9.11,但问题仍然存在。
以为是pip的问题,所以也升级了它,并尝试了pip和pip3,都不起作用。
虽然我能够通过虚拟环境安装它,但在导入模块时遇到了问题。
因此,如果您有任何其他建议,或者它们是我的系统的问题。
我目前正在开发的Python版本是3.11.9。
附注- 无法复制整个错误,因为它超出了正文字数限制。
subprocess.CalledProcessError:命令'['cmake','--build','.', '--config'、'Release'、'--'、'/m']' 返回非零退出状态 1。 [输出结束]
这似乎是安装 dlib 所需的 cmake 的错误。尝试通过安装更新的版本来更新它,因为它显示了弃用警告。
观看此视频,了解如何在 Windows 中下载和安装。