我想在Python项目中使用OpenCV,因此我想安装dlib库.我运行命令pip install dlib,它给了我以下错误:

  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: dlib
  Building wheel for dlib (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building wheel for dlib (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]
      running bdist_wheel
      running build
      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: 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

由于错误是Cmake must be installed,我安装Cmake使用pip install cmake,但错误仍然存在.所以我也安装了cmake here,但错误仍然存在.

推荐答案

由于您使用的是anacoda,您可能已经打乱了运行环境.你的错误并不能让你了解实际上发生了什么,但一个临时的方法,无论它是消极的,可以修复你的错误.

安装cmake后,如链接中提到的,回答安装包在根目录下使用sudo pip install cmakesudo pip install dlib.

然后,您可以使用sys模块导入根目录中的模块,如下所示:

import sys

sys.path.insert(0, '/usr/path/to/modules/dlib')

Python相关问答推荐

多处理代码在while循环中不工作

Python:在类对象内的字典中更改所有键的索引,而不是仅更改一个键

如何才能知道Python中2列表中的巧合.顺序很重要,但当1个失败时,其余的不应该失败或是0巧合

rame中不兼容的d类型

对整个 pyramid 进行分组与对 pyramid 列子集进行分组

需要计算60,000个坐标之间的距离

pandas在第1列的id,第2列的标题,第3列的值,第3列的值?

有没有一种ONE—LINER的方法给一个框架的每一行一个由整数和字符串组成的唯一id?

将pandas导出到CSV数据,但在此之前,将日期按最小到最大排序

如何从需要点击/切换的网页中提取表格?

如何使用SentenceTransformers创建矢量嵌入?

合并帧,但不按合并键排序

CommandeError:模块numba没有属性generated_jit''''

Django admin Csrf令牌未设置

lityter不让我输入左边的方括号,'

高效生成累积式三角矩阵

为什么在Python中00是一个有效的整数?

如何将验证器应用于PYDANC2中的EACHY_ITEM?

解析CSV文件以将详细信息添加到XML文件

如何在不遇到IndexError的情况下将基数10的整数转换为基数80?