背景:工作需要在linux環境下安裝dlib,conda安裝完成后再pip里面找不到dlib,所以導包失敗,因此嘗試用dlib的源碼安裝
1、源碼下載:
網址:https://pypi.org/simple/dlib/
我的是python3.6.6,試了不少次才發現19.15.0可以使用,python3.7可以用19.17.0
2、下載完成后解壓,安裝
python setup.py install
可能遇到的問題:
1、AttributeError: Module Pip has no attribute 'main'
原因:版本不對,比如我之前用19.8.1版本就不可以,具體原因沒有深究
2、 Cannot find appropriate C compiler on this system.
解決:缺少gcc, suao apt install gcc
3、 Compile error: Cannot find a C++ compiler that supports both C++11 and the specified C++ flags
解決: sudo apt-get install g++
4、 Cannot find appropriate Makefile processor on this system
解決:缺少make, sudo apt install make
5、 CMake must be installed to build the following extensions: dlib
解決:缺少cmake 下載:https://cmake.org/download/ , 解壓后:
./bootstrap make && make install