windows环境pip无法安装dlib库的终极解决

楚天乐 562 0 条

问题

机器学习需要安装dlib库,网上搜索

解决方案在最底部

网上搜索的解决方案

pip install cmake
pip install boost
pip install dlib

然而,在安装dlib的时候,错误原因不仅限于没有安装cmake。

报错如下

Collecting dlib
  Using cached dlib-19.24.0.tar.gz (3.2 MB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: dlib
  Building wheel for dlib (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [320 lines of output]
      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
      Building extension for Python 3.8.8 (default, Apr 13 2021, 15:08:03) [MSC v.1916 64 bit (AMD64)]
      Invoking CMake setup: 'cmake C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\lib.win-amd64-3.8 -DPYTHON_EXECUTABLE=C:\ProgramData\Anaconda3\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\lib.win-amd64-3.8 -A x64'
      -- Building for: Visual Studio 17 2022
      -- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19044.
      -- The C compiler identification is MSVC 19.32.31329.0
      -- The CXX compiler identification is MSVC 19.32.31329.0
      -- Detecting C compiler ABI info
      -- Detecting C compiler ABI info - done
      -- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/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/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe - skipped
      -- Detecting CXX compile features
      -- Detecting CXX compile features - done
      -- Found PythonInterp: C:/ProgramData/Anaconda3/python.exe (found version "3.8.8")
      -- Found PythonLibs: C:/ProgramData/Anaconda3/libs/Python38.lib
      -- pybind11 v2.2.4
      -- Using CMake version: 3.22.5
      -- Compiling dlib version: 19.24.0
      -- 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 BLAS and LAPACK
      -- Searching for BLAS and LAPACK
      -- Looking for pthread.h
      -- Looking for pthread.h - not found
      -- Found Threads: TRUE
      -- Found CUDA: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.2 (found suitable version "11.2", minimum required is "7.5")
      -- Looking for cuDNN install...
      -- Found cuDNN: C:/tools/cudnn-11.2-windows-x64-v8.1.1.33/cuda/lib/x64/cudnn.lib
      -- Building a CUDA test project to see if your compiler is compatible with CUDA...
      -- *****************************************************************************************************************
      -- *** CUDA was found but your compiler failed to compile a simple CUDA program so dlib isn't going to use CUDA.
      -- *** The output of the failed CUDA test compile is shown below:
      -- ***
      -- ***   Change Dir: C:/Users/shyan/AppData/Local/Temp/pip-install-g2xfkj5d/dlib_6582d86d1c13456bb92e2e45ecaaae84/build/temp.win-amd64-3.8/Release/dlib_build/cuda_test_build
         ***
         ***   Run Build Command(s):C:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe ALL_BUILD.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=17.0 /v:m && Microsoft (R) Build Engine version 17.2.1+52cd2da31 for .NET Framework
         ***   Copyright (C) Microsoft Corporation. All rights reserved.
         ***
         ***   C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(524,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\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\cuda_test_build\ZERO_CHECK.vcxproj]
         ***     Checking Build System
         ***   C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(524,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\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\cuda_test_build\cuda_test.vcxproj]
         ***     Building NVCC (Device) object CMakeFiles/cuda_test.dir/Debug/cuda_test_generated_cuda_test.cu.obj
         ***     cuda_test.cu
         ***   C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\include\crt/host_config.h(160): fatal error C1189: #error:  -- unsupported Microsoft Visual Studio version! Only the versions between 2017 and 2019 (inclusive) are supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk. [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\cuda_test_build\cuda_test.vcxproj]
         ***   CUSTOMBUILD : nvcc warning : The 'compute_35', 'compute_37', 'compute_50', 'sm_35', 'sm_37' and 'sm_50' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning). [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\cuda_test_build\cuda_test.vcxproj]
         ***   CUSTOMBUILD : nvcc warning : The -std=c++11 flag is not supported with the configured host compiler. Flag will be ignored. [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\cuda_test_build\cuda_test.vcxproj]
         ***     CMake Error at cuda_test_generated_cuda_test.cu.obj.Debug.cmake:216 (message):
         ***       Error generating
         ***       C:/Users/shyan/AppData/Local/Temp/pip-install-g2xfkj5d/dlib_6582d86d1c13456bb92e2e45ecaaae84/build/temp.win-amd64-3.8/Release/dlib_build/cuda_test_build/CMakeFiles/cuda_test.dir//Debug/cuda_test_generated_cuda_test.cu.obj
         ***
         ***
         ***   C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(245,5): error MSB8066: Custom build for 'C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\cmake_utils\test_for_cuda\cuda_test.cu;C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\cmake_utils\test_for_cuda\CMakeLists.txt' exited with code 1. [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\cuda_test_build\cuda_test.vcxproj]
         ***
         ***
      -- *****************************************************************************************************************
      -- Disabling CUDA support for dlib.  DLIB WILL NOT USE CUDA
      -- C++11 activated.
      -- Configuring done
      -- Generating done
      -- Build files have been written to: C:/Users/shyan/AppData/Local/Temp/pip-install-g2xfkj5d/dlib_6582d86d1c13456bb92e2e45ecaaae84/build/temp.win-amd64-3.8/Release
      Invoking CMake build: 'cmake --build . --config Release -- /m'
      Microsoft (R) Build Engine version 17.2.1+52cd2da31 for .NET Framework
      Copyright (C) Microsoft Corporation. All rights reserved.

      C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(524,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\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\ZERO_CHECK.vcxproj]
        Checking Build System
      C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(524,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\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\dlib.vcxproj]
        Building Custom Rule C:/Users/shyan/AppData/Local/Temp/pip-install-g2xfkj5d/dlib_6582d86d1c13456bb92e2e45ecaaae84/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
        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
        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
        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
        gzwrite.c
        infback.c
      C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\external\zlib\gzread.c(319,17): warning C4267: “=”: 从“size_t”转换到“unsigned int”,可能丢失数据 [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\dlib.vcxproj]
        inffast.c
        inflate.c
        inftrees.c
        trees.c
        uncompr.c
      C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\external\zlib\gzread.c(400,11): warning C4267: “=”: 从“size_t”转换到“unsigned int”,可能丢失数据 [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\dlib.vcxproj]
      C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\external\zlib\gzwrite.c(212,24): warning C4267: “=”: 从“size_t”转换到“unsigned int”,可能丢失数据 [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\dlib.vcxproj]
        zutil.c
        jaricom.c
      C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\external\zlib\gzread.c(472,11): warning C4267: “=”: 从“size_t”转换到“int”,可能丢失数据 [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\dlib.vcxproj]
      C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\external\zlib\gzwrite.c(232,21): warning C4267: “=”: 从“size_t”转换到“unsigned int”,可能丢失数据 [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\dlib.vcxproj]
      C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\external\zlib\gzwrite.c(371,11): warning C4267: “=”: 从“size_t”转换到“int”,可能丢失数据 [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\dlib.vcxproj]
        jcapimin.c
        jcapistd.c
        jcarith.c
        jccoefct.c
        jccolor.c
        jcdctmgr.c
        jchuff.c
        jcinit.c
        jcmainct.c
        jcmarker.c
        jcmaster.c
        jcomapi.c
        jcparam.c
        jcprepct.c
        jcsample.c
        jdapimin.c
        jdapistd.c
        jdarith.c
        jdatadst.c
        jdatasrc.c
        jdcoefct.c
      C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\external\libjpeg\jdatadst.c(185,34): warning C4267: “=”: 从“size_t”转换到“unsigned long”,可能丢失数据 [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\dlib.vcxproj]
        jdcolor.c
        jddctmgr.c
        jdhuff.c
        jdinput.c
        jdmainct.c
        jdmarker.c
        jdmaster.c
        jdmerge.c
        jdpostct.c
        jdsample.c
        jerror.c
        jfdctflt.c
        jfdctfst.c
        jfdctint.c
        jidctflt.c
        jidctfst.c
        jidctint.c
        jmemmgr.c
        jmemnobs.c
        jquant1.c
        jquant2.c
        jutils.c
      C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\external\libjpeg\jmemmgr.c(307,47): warning C4267: “+=”: 从“size_t”转换到“long”,可能丢失数据 [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\dlib.vcxproj]
      C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\external\libjpeg\jerror.c(193,5): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\dlib.vcxproj]
      C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\external\libjpeg\jmemmgr.c(367,46): warning C4267: “+=”: 从“size_t”转换到“long”,可能丢失数据 [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\dlib.vcxproj]
      C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\external\libjpeg\jerror.c(195,5): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\dlib.vcxproj]
      C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\external\libjpeg\jmemmgr.c(977,35): warning C4267: “-=”: 从“size_t”转换到“long”,可能丢失数据 [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\dlib.vcxproj]
      C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\external\libjpeg\jmemmgr.c(991,35): warning C4267: “-=”: 从“size_t”转换到“long”,可能丢失数据 [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\dlib.vcxproj]
      C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\external\libjpeg\jmemmgr.c(1107,19): warning C4996: 'getenv': This function or variable may be unsafe. Consider using _dupenv_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\dlib.vcxproj]
      C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\dlib\external\libjpeg\jmemmgr.c(1110,11): warning C4996: 'sscanf': This function or variable may be unsafe. Consider using sscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\dlib.vcxproj]
        dlib.vcxproj -> C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\dlib_build\Release\dlib19.24.0_release_64bit_msvc1932.lib
      C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(524,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\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj]
        Building Custom Rule C:/Users/shyan/AppData/Local/Temp/pip-install-g2xfkj5d/dlib_6582d86d1c13456bb92e2e45ecaaae84/tools/python/CMakeLists.txt
        dlib.cpp
        matrix.cpp
        vector.cpp
        svm_c_trainer.cpp
        svm_rank_trainer.cpp
        decision_functions.cpp
        other.cpp
        basic.cpp
        cca.cpp
        sequence_segmenter.cpp
        svm_struct.cpp
        image.cpp
        image2.cpp
        image3.cpp
        image4.cpp
        rectangles.cpp
      C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的,则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\dlib.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj]
      C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的,则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\matrix.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj]
      C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的,则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\cca.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj]
      C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的,则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\decision_functions.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj]
      C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的,则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\other.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj]
      C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的,则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\svm_rank_trainer.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj]
      C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的,则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\vector.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj]
      C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的,则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\image2.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj]
        object_detection.cpp
      C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的,则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\image.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj]
      C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的,则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\basic.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj]
        shape_predictor.cpp
      C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的,则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\rectangles.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj]
      C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的,则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\image4.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj]
        correlation_tracker.cpp
      C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的,则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\svm_c_trainer.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj]
      C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的,则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\sequence_segmenter.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj]
      C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的,则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\image3.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj]
      C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的,则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\svm_struct.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj]
        face_recognition.cpp
        cnn_face_detector.cpp
        global_optimization.cpp
        image_dataset_metadata.cpp
        numpy_returns.cpp
        line.cpp
        gui.cpp
      C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的,则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\object_detection.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj]
      C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的,则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\shape_predictor.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj]
      C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的,则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\correlation_tracker.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj]
      C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的,则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\face_recognition.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj]
      C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的,则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\global_optimization.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj]
      C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的,则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\cnn_face_detector.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj]
      C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的,则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\image_dataset_metadata.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj]
      C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的,则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\numpy_returns.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj]
      C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的,则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\line.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj]
      C:\ProgramData\Anaconda3\Library\include\gif_lib.h(286,61): error C2734: “GifAsciiTable8x8”: 如果不是外部的,则 必须初始化常量对象 (编译源文件 C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\tools\python\src\gui.cpp) [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-3.8\Release\_dlib_pybind11.vcxproj]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\setup.py", line 222, in <module>
          setup(
        File "C:\ProgramData\Anaconda3\lib\site-packages\setuptools\__init__.py", line 165, in setup
          return distutils.core.setup(**attrs)
        File "C:\ProgramData\Anaconda3\lib\distutils\core.py", line 148, in setup
          dist.run_commands()
        File "C:\ProgramData\Anaconda3\lib\distutils\dist.py", line 966, in run_commands
          self.run_command(cmd)
        File "C:\ProgramData\Anaconda3\lib\distutils\dist.py", line 985, in run_command
          cmd_obj.run()
        File "C:\ProgramData\Anaconda3\lib\site-packages\wheel\bdist_wheel.py", line 299, in run
          self.run_command('build')
        File "C:\ProgramData\Anaconda3\lib\distutils\cmd.py", line 313, in run_command
          self.distribution.run_command(command)
        File "C:\ProgramData\Anaconda3\lib\distutils\dist.py", line 985, in run_command
          cmd_obj.run()
        File "C:\ProgramData\Anaconda3\lib\distutils\command\build.py", line 135, in run
          self.run_command(cmd_name)
        File "C:\ProgramData\Anaconda3\lib\distutils\cmd.py", line 313, in run_command
          self.distribution.run_command(command)
        File "C:\ProgramData\Anaconda3\lib\distutils\dist.py", line 985, in run_command
          cmd_obj.run()
        File "C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\setup.py", line 134, in run
          self.build_extension(ext)
        File "C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\setup.py", line 174, in build_extension
          subprocess.check_call(cmake_build, cwd=build_folder)
        File "C:\ProgramData\Anaconda3\lib\subprocess.py", line 364, 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
  Running setup.py clean for dlib
Failed to build dlib
Installing collected packages: dlib
  Running setup.py install for dlib ... /

关键错误

#error:  -- unsupported Microsoft Visual Studio version! Only the versions between 2017 and 2019 (inclusive) are supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk. [C:\Users\shyan\AppData\Local\Temp\pip-install-g2xfkj5d\dlib_6582d86d1c13456bb92e2e45ecaaae84\build\temp.win-amd64-

我推测关键错误原因还是visual studio版本的问题。我本机有vs2019和vs2022,python应该是使用了vs2022。然而这个版本不被支持

解决方法

下载dlib包,手动执行setup.py,加上参数

下载地址: https://github.com/davisking/dlib/tags

解压缩执行命令,cmd打开目录

C:\Users\machineA\Desktop\dlib-19.24>> python setup.py install --no DLIB_GIF_SUPPORT
。。。。。
creating dist
creating 'dist\dlib-19.24.0-py3.8-win-amd64.egg' and adding 'build\bdist.win-amd64\egg' to it
removing 'build\bdist.win-amd64\egg' (and everything under it)
Processing dlib-19.24.0-py3.8-win-amd64.egg
creating c:\programdata\anaconda3\lib\site-packages\dlib-19.24.0-py3.8-win-amd64.egg
Extracting dlib-19.24.0-py3.8-win-amd64.egg to c:\programdata\anaconda3\lib\site-packages
Adding dlib 19.24.0 to easy-install.pth file

Installed c:\programdata\anaconda3\lib\site-packages\dlib-19.24.0-py3.8-win-amd64.egg
Processing dependencies for dlib==19.24.0
Finished processing dependencies for dlib==19.24.0

打赏

微信打赏

支付宝打赏



发表我的评论
昵称 (必填)
邮箱 (必填)
网址
执行时间: 52.494049072266 毫秒