安装依赖报错:ERROR: Failed to build installable wheels for some pyproject.toml based projects (dlib)

在安装dlib19.24.0时候报错:下面是各个尝试的解决办法:
1、下载cmake软件:https://cmake.org/download/
进入官方下载.msi文件安装,并将软件加入系统环境变量,然后pip install dlib==19.24.0不行
2、下载whl文件或者包的源文件:

1、官方压缩包:https://pypi.org/project/dlib/19.24.0/
2、whl文件:https://www.piwheels.org/project/dlib/
3、官方源文件:https://pypi.org/simple/dlib/

下载你自己版本的包,如果有whl就用whl,没有就下载对应的压缩包文件,
下面是具体的执行代码,先直接安装报错,发现cmake版本过高,卸载然后安装低版本的:https://pypi.org/simple/dlib/,然后再安装,成功!!

d:\packet>pip install dlib-19.24.0.tar.gz
Processing .\dlib-19.24.0.tar.gz
  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
  ╰─> [74 lines of output]
      C:\Users\LLM\AppData\Local\Temp\pip-req-build-nikxi5_r\setup.py:194: SetuptoolsDeprecationWarning: The test command is disabled and references to it are deprecated.
      !!

              ********************************************************************************
              Please remove any references to `setuptools.command.test` in all supported versions of the affected package.

              This deprecation is overdue, please update your project and remove deprecated
              calls to avoid build errors in the future.
              ********************************************************************************

      !!
        from setuptools.command.test import test as TestCommand
      C:\Users\LLM\anaconda3\envs\video-retalking\lib\site-packages\setuptools\_distutils\dist.py:261: UserWarning: Unknown distribution option: 'tests_require'
        warnings.warn(msg)
      running bdist_wheel
      running build
      running build_py
      running build_ext
      C:\Users\LLM\AppData\Local\Temp\pip-req-build-nikxi5_r\setup.py:129: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
        if LooseVersion(cmake_version) < '3.1.0':
      Building extension for Python 3.8.20 (default, Oct  3 2024, 15:19:54) [MSC v.1929 64 bit (AMD64)]    
      Invoking CMake setup: 'cmake C:\Users\LLM\AppData\Local\Temp\pip-req-build-nikxi5_r\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\LLM\AppData\Local\Temp\pip-req-build-nikxi5_r\build\lib.win-amd64-cpython-38 -DPYTHON_EXECUTABLE=C:\Users\LLM\anaconda3\envs\video-retalking\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\LLM\AppData\Local\Temp\pip-req-build-nikxi5_r\build\lib.win-amd64-cpython-38 -A x64'
      -- Building for: Visual Studio 17 2022
      CMake Error at CMakeLists.txt:2 (CMAKE_MINIMUM_REQUIRED):
        Compatibility with CMake < 3.5 has been removed from CMake.

        Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
        to tell CMake that the project requires at least <min> but has been updated
        to work with policies introduced by <max> or earlier.

        Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway.


      -- Configuring incomplete, errors occurred!
      Traceback (most recent call last):
        File "", line 2, in <module>
        File "", line 34, in <module>
        File "C:\Users\LLM\AppData\Local\Temp\pip-req-build-nikxi5_r\setup.py", line 222, in <module>      
          setup(
        File "C:\Users\LLM\anaconda3\envs\video-retalking\lib\site-packages\setuptools\__init__.py", line 117, in setup
          return distutils.core.setup(**attrs)
        File "C:\Users\LLM\anaconda3\envs\video-retalking\lib\site-packages\setuptools\_distutils\core.py", line 183, in setup
          return run_commands(dist)
        File "C:\Users\LLM\anaconda3\envs\video-retalking\lib\site-packages\setuptools\_distutils\core.py", line 199, in run_commands
          dist.run_commands()
        File "C:\Users\LLM\anaconda3\envs\video-retalking\lib\site-packages\setuptools\_distutils\dist.py", line 954, in run_commands
          self.run_command(cmd)
        File "C:\Users\LLM\anaconda3\envs\video-retalking\lib\site-packages\setuptools\dist.py", line 950, in run_command
          super().run_command(command)
        File "C:\Users\LLM\anaconda3\envs\video-retalking\lib\site-packages\setuptools\_distutils\dist.py", line 973, in run_command
          cmd_obj.run()
        File "C:\Users\LLM\anaconda3\envs\video-retalking\lib\site-packages\setuptools\command\bdist_wheel.py", line 398, in run
          self.run_command("build")
        File "C:\Users\LLM\anaconda3\envs\video-retalking\lib\site-packages\setuptools\_distutils\cmd.py", line 316, in run_command
          self.distribution.run_command(command)
        File "C:\Users\LLM\anaconda3\envs\video-retalking\lib\site-packages\setuptools\dist.py", line 950, in run_command
          super().run_command(command)
        File "C:\Users\LLM\anaconda3\envs\video-retalking\lib\site-packages\setuptools\_distutils\dist.py", line 973, in run_command
          cmd_obj.run()
        File "C:\Users\LLM\anaconda3\envs\video-retalking\lib\site-packages\setuptools\_distutils\command\build.py", line 135, in run
          self.run_command(cmd_name)
        File "C:\Users\LLM\anaconda3\envs\video-retalking\lib\site-packages\setuptools\_distutils\cmd.py", line 316, in run_command
          self.distribution.run_command(command)
        File "C:\Users\LLM\anaconda3\envs\video-retalking\lib\site-packages\setuptools\dist.py", line 950, in run_command
          super().run_command(command)
        File "C:\Users\LLM\anaconda3\envs\video-retalking\lib\site-packages\setuptools\_distutils\dist.py", line 973, in run_command
          cmd_obj.run()
        File "C:\Users\LLM\AppData\Local\Temp\pip-req-build-nikxi5_r\setup.py", line 134, in run
          self.build_extension(ext)
        File "C:\Users\LLM\AppData\Local\Temp\pip-req-build-nikxi5_r\setup.py", line 171, in build_extension
          subprocess.check_call(cmake_setup, cwd=build_folder)
        File "C:\Users\LLM\anaconda3\envs\video-retalking\lib\subprocess.py", line 364, in check_call      
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\LLM\\AppData\\Local\\Temp\\pip-req-build-nikxi5_r\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\LLM\\AppData\\Local\\Temp\\pip-req-build-nikxi5_r\\build\\lib.win-amd64-cpython-38', '-DPYTHON_EXECUTABLE=C:\\Users\\LLM\\anaconda3\\envs\\video-retalking\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\LLM\\AppData\\Local\\Temp\\pip-req-build-nikxi5_r\\build\\lib.win-amd64-cpython-38', '-A', 'x64']' 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
ERROR: Failed to build installable wheels for some pyproject.toml based projects (dlib)

d:\packet>pip show cmake
Name: cmake
Version: 4.0.0
Summary: CMake is an open-source, cross-platform family of tools designed to build, test and package software
Home-page: https://cmake.org
Author:
Author-email: Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>
License: Apache 2.0
Location: c:\users\llm\anaconda3\envs\video-retalking\lib\site-packages
Requires:
Required-by:
d:\packet>conda install -c conda-forge dlib==19.24.0
Channels:
 - conda-forge
 - defaults
Platform: win-64
Collecting package metadata (repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: C:\Users\LLM\anaconda3\envs\video-retalking

  added / updated specs:
    - dlib==19.24.0


The following NEW packages will be INSTALLED:

  dlib               conda-forge/win-64::dlib-19.24.0-py38h2e7587d_4
  intel-openmp       conda-forge/win-64::intel-openmp-2024.2.1-h57928b3_1083
  libblas            conda-forge/win-64::libblas-3.9.0-31_h641d27c_mkl
  libcblas           conda-forge/win-64::libcblas-3.9.0-31_h5e41251_mkl
  libhwloc           conda-forge/win-64::libhwloc-2.11.2-default_ha69328c_1001
  liblapack          conda-forge/win-64::liblapack-3.9.0-31_h1aa476e_mkl
  liblzma-devel      conda-forge/win-64::liblzma-devel-5.8.1-h2466b09_0
librsvg: The post-link script did not complete.
To take advantage of gdk-pixbuf's support for librsvg, please run:
    C:\Users\LLM\anaconda3\envs\video-retalking\Scripts\.gdk-pixbuf-post-link.bat

done
ERROR conda.core.link:_execute(938): An error occurred while installing package 'conda-forge::gdk-pixbuf-2.
Rolling back transaction: done

UnicodeDecodeError('gbk', b"g_module_open() failed for C:\\Users\\LLM\\anaconda3\\envs\\video-retalking\\L)
()


d:\packet>python -c "import dlib"
Traceback (most recent call last):
  File "", line 1, in <module>
ModuleNotFoundError: No module named 'dlib'

d:\packet>pip uninstall cmake            
Found existing installation: cmake 4.0.0
Uninstalling cmake-4.0.0:
  Would remove:
    c:\users\llm\anaconda3\envs\video-retalking\lib\site-packages\cmake-4.0.0.dist-info\*
    c:\users\llm\anaconda3\envs\video-retalking\lib\site-packages\cmake\*
    c:\users\llm\anaconda3\envs\video-retalking\scripts\ccmake.exe
    c:\users\llm\anaconda3\envs\video-retalking\scripts\cmake.exe
    c:\users\llm\anaconda3\envs\video-retalking\scripts\cpack.exe
    c:\users\llm\anaconda3\envs\video-retalking\scripts\ctest.exe
Proceed (Y/n)? y
  Successfully uninstalled cmake-4.0.0

d:\packet>pip install cmake=3.31 -i https://mirrors.aliyun.com/pypi/simple
ERROR: Invalid requirement: 'cmake=3.31': Expected end or semicolon (after name and no valid version specifier)
    cmake=3.31
         ^
Hint: = is not a valid operator. Did you mean == ?

d:\packet>pip install cmake==3.31 -i https://mirrors.aliyun.com/pypi/simple
Looking in indexes: https://mirrors.aliyun.com/pypi/simple
Collecting cmake==3.31
  Downloading https://mirrors.aliyun.com/pypi/packages/2e/4c/d2dce10f8527250b82cf64f642c4797648a001ed4a3fdb84ed611a2e6109/cmake-3.31.0-py3-none-win_amd64.whl (36.4 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 36.4/36.4 MB 2.3 MB/s eta 0:00:00
WARNING: The candidate selected for download or install is a yanked version: 'cmake' candidate (version 3.31.0 at https://mirrors.aliyun.com/pypi/packages/2e/4c/d2dce10f8527250b82cf64f642c4797648a001ed4a3fdb84ed611a2e6109/cmake-3.31.0-py3-none-win_amd64.whl#sha256=445b944db723ed4aaa6c457b6bda0ef09a29c464070ff2f8d2b365464a5328c6 (from https://mirrors.aliyun.com/pypi/simple/cmake/) (requires-python:>=3.7))
Reason for being yanked: see https://github.com/scikit-build/cmake-python-distributions/issues/557
Installing collected packages: cmake
Successfully installed cmake-3.31.0

d:\packet>pip install dlib-19.24.0.tar.gz                                  
Processing .\dlib-19.24.0.tar.gz
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: dlib
  Building wheel for dlib (setup.py) ... done
  Created wheel for dlib: filename=dlib-19.24.0-cp38-cp38-win_amd64.whl size=2956266 sha256=5ff0a1a8fca2c6893e1a633a4fd8dfaca78b8ba840be62bdecc010c37f087f16
  Stored in directory: c:\users\llm\appdata\local\pip\cache\wheels\c4\70\92\15077cc5a7202776ac86f6454a2e5be9e48d5925f4016d6a59
Successfully built dlib
Installing collected packages: dlib
Successfully installed dlib-19.24.0

你可能感兴趣的:(pip,dlib,python)