Linux环境安装Dlib——以Centos7为例

MoyiTech
2022-10-12 / 0 评论 / 328 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2022年12月31日,已超过476天没有更新,若内容或图片失效,请留言反馈。

l95efonc.png
Dlib是较流行的人脸识别的开源库,使用c++编写,里面包含了许多的机器学习算法,在python中也可以使用。Dlib保持着很好的更新节奏,文档也写得相当清晰,涉及到的资源都有标明在哪里下载,是一个优秀的人脸识别开源库。
在使用pip直接安装dlib时候大都会报各种各样的错误
Python的安装看这里: Linux环境安装Python3——以Centos7为例
笔者现在使用的环境为CentOS7.6、Python3.6.8
首先我们先使用pip安装下面几个库

pip3 install scikit-build
pip3 install cmake
pip3 install boost

如果未安装wget,输入以下命令安装

yum install wget

接下来从官网下载dlib安装包

wget http://dlib.net/files/dlib-19.19.tar.bz2

下载完成后解压

tar -jxvf dlib-19.19.tar.bz2

如果报错,使用以下命令安装bzip2

yum -y install bzip2

解压完成后,进入dlib目录

cd ./dlib-19.19
python3 setup.py install

正常情况下应该就可以完成安装了,不过笔者在安装过程中还遇到了以下问题

gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python3.6m -I/tmp/pip-build-env-w9_ayv83/overlay/lib64/python3.6/site-packages/numpy/core/include -c ConfigSpace/hyperparameters.c -o build/temp.linux-x86_64-3.6/ConfigSpace/hyperparameters.o
  ConfigSpace/hyperparameters.c:6:20: 致命错误:Python.h:没有那个文件或目录
   #include "Python.h"
                      ^
  编译中断。
  /tmp/pip-build-env-w9_ayv83/overlay/lib/python3.6/site-packages/setuptools/dist.py:694: UserWarning: Usage of dash-separated 'description-file' will not be supported in future versions. Please use the underscore name 'description_file' instead
    % (opt, underscore_opt))
  error: command 'gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for ConfigSpace
Failed to build ConfigSpace
ERROR: Could not build wheels for ConfigSpace which use PEP 517 and cannot be installed directly

意思是缺少Python3编译环境
可以通过安装python3-devel解决

yum install python3-devel

之后就可以愉快地python3 setup.py install啦

4

评论 (0)

取消