Mac OSX下安装dlib (Python)

1.在安装Dlib库之前需要安装的库:opencv,numpy

2.安装Xquartz2.7.11

Xquartz是执行Unix程序的图形窗口环境,为了兼容Unix和Linux下移植过来的程序就需要安装,dlib需要X11,但mac没有自带,所以直接上网址下载安装就好了

地址:https://www.xquartz.org/

默认安装目录为/opt/X11,需要在/usr/local/X11下面创建软链接,需要重启

cd /usr/local/opt
ln -s /opt/X11 X11

3.安装Dlib

网上这么多种方法,踩了这么多坑,最后还是直接在Git上面下载成功了

git clone https://github.com/davisking/dlib.git

下载后解压安装Dlib

cd dlib/examples
mkdir build
cd build
cmake .. 
cmake --build . --config Release

安装python模块

cd dlib
sudo python setup.py install
python
import dlib
#如果没有错就对啦

在执行 sudo python setup.py install 的时候 ,可能出现错误

Could NOT find Boost

这个时候说明boost没有安装好,安装文件给出了解决办法

*****************************************************************
--  To compile Boost.Python yourself download boost from boost.org and then go into the boost root folder
--  and run these commands:
--     ./bootstrap.sh --with-libraries=python
--     ./b2
--     sudo ./b2 install *****************************************************************

先去下载好boost,然后在boost所在的文件夹执行命令

这个时候再执行 import dlib 不会报错

但是执行的时候可能会报错

Library not loaded: libboost_python.dylib

这是因为升级了OSX,苹果的System Integrity Protection (SIP),不管你是不是在根用户下,一些软件程序都无法正常运行,这个时候进入苹果恢复模式(开机黑屏时按command+R)

然后输入命令

csrutil disable

现在就可以了

参考文档:

http://www.macworld.com/article/2986118/security/how-to-modify-system-integrity-protection-in-el-capitan.html

http://blog.csdn.net/quincuntial/article/details/53572415

posted @ 2017-07-26 00:40  as3asddd  阅读(4822)  评论(1编辑  收藏  举报