1.在安裝Dlib庫之前需要安裝的庫:opencv,numpy
2.安裝Xquartz2.7.11
Xquartz是執行Unix程序的圖形窗口環境,為了兼容Unix和Linux下移植過來的程序就需要安裝,dlib需要X11,但mac沒有自帶,所以直接上網址下載安裝就好了
默認安裝目錄為/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
#如果沒有錯就對啦
錯誤記錄
mac升級到10.12(macOS Sierra),執行git命令,出現如下錯誤
$ git
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
$ git
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
解決方法
xcode-select --install
彈出一個界面,安裝提示安裝即可