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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM