一、问题描述
缺少正确配置的 CMake,导致无法成功安装 dlib
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
Building wheel for face-recognition-models (setup.py) ... done
Created wheel for face-recognition-models: filename=face_recognition_models-0.3.0-py2.py3-none-any.whl size=100566211 sha256=71a6219cb2cb737c3c5589cbd43c0d38eadb3d64e01dc321c38e4f123cc88721
Stored in directory: /root/.cache/pip/wheels/04/52/ec/9355da79c29f160b038a20c784db2803c2f9fa2c8a462c176a
Successfully built omagent_core func-timeout jsonpath wikipedia face-recognition-models
Failed to build dlib
ERROR: Failed to build installable wheels for some pyproject.toml based projects (dlib)
或者
subprocess.CalledProcessError: Command '['cmake', '/tmp/pip-install-8zeluddm/dlib_43702e1b07ce418a82086035bea97626/tools/python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/tmp/pip-install-8zeluddm/dlib_43702e1b07ce418a82086035bea97626/build/lib.linux-x86_64-cpython-311', '-DPYTHON_EXECUTABLE=/opt/conda/envs/omagent/bin/python', '-DDLIB_USE_FFMPEG=OFF', '-DCMAKE_BUILD_TYPE=Release']' 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
Successfully built omagent_core
Failed to build dlib
ERROR: Failed to build installable wheels for some pyproject.toml based projects (dlib)
二、解决方案
参考安装dlib包报错解决_building wheel for dlib (pyproject.toml) did not r-优快云博客
1. 重新安装 CMake
sudo apt-get update
sudo apt-get install cmake -y
2. 安装必要的编译库
sudo apt-get install build-essential cmake libboost-all-dev libopenblas-dev liblapack-dev -y
3. 添加环境变量
sudo vim ~/.bashrc
4. 按 i写入以下内容:
export PATH="/usr/local/bin:$PATH"
5. ESC 退出写入,: wq 退出文件,运行下述内容使其生效
source ~/.bashrc
6. 重新安装
conda install -c https://conda.anaconda.org/conda-forge dlib -y