運(yùn)行環(huán)境
Mac OS 10.12.6
python 3.6.2
pip 9.0.1
gcc 7.2.0
問題
無法使用pip install xgboost
安裝xgboost
$pip install xgboost
Collecting xgboost
Using cached xgboost-0.6a2.tar.gz
Complete output from command python setup.py egg_info:
rm -f -rf build build_plugin lib bin ~ /~ //~ ///~ /.o //.o ///.o xgboost
which: no gcc-5 in (/Users/yong.zhang/entity-embedding-rossmann/venv/bin:/usr/local/opt/coreutils/libexec/gnubin:/usr/local/bin:/Users/yong.zhang/anaconda3/bin:/Users/yong.zhang/Applications/anaconda/bin :/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/Cellar/hadoop/2.8.1/libexec/sbin:/usr/local/Cellar/hadoop/2.8.1/libexec/bin)
...
make: *** [build/learner.o] Error 127
make: *** Waiting for unfinished jobs....
clang-omp++ -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -Idmlc-core/include -Irabit/include -fPIC -fopenmp -MM -MT build/logging.o src/logging.cc >build/logging.d
/bin/sh: clang-omp++: command not found
make: *** [build/logging.o] Error 127
-----------------------------
Building multi-thread xgboost failed
Start to build single-thread xgboost
rm -f -rf build build_plugin lib bin ~ /~ //~ ///~ /.o //.o ///.o xgboost
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/x6/82p0vbnx3kj9ffcvr35y_tr40000gp/T/pip-build-jl7jcggp/xgboost/setup.py", line 29, in <module>
LIB_PATH = libpath'find_lib_path'
File "/private/var/folders/x6/82p0vbnx3kj9ffcvr35y_tr40000gp/T/pip-build-jl7jcggp/xgboost/xgboost/libpath.py", line 45, in find_lib_path
'List of candidates:\n' + ('\n'.join(dll_path)))
XGBoostLibraryNotFound: Cannot find XGBoost Libarary in the candicate path, did you install compilers and run build.sh in root path?
List of candidates:
/private/var/folders/x6/82p0vbnx3kj9ffcvr35y_tr40000gp/T/pip-build-jl7jcggp/xgboost/xgboost/libxgboost.so
/private/var/folders/x6/82p0vbnx3kj9ffcvr35y_tr40000gp/T/pip-build-jl7jcggp/xgboost/xgboost/../../lib/libxgboost.so
/private/var/folders/x6/82p0vbnx3kj9ffcvr35y_tr40000gp/T/pip-build-jl7jcggp/xgboost/xgboost/./lib/libxgboost.so
出錯(cuò)原因
pip上的xgboost當(dāng)前只支持gcc5, 而Mac OS X大多數(shù)gcc都已經(jīng)是gcc6以上的版本,比如我的是gcc7
解決辦法
感謝github门岔,基友總是在需要的時(shí)候出現(xiàn),
參考Problems while installing in OSX 10.11.6? #1501, 找到解決辦法
$ brew install gcc@5
$ pip install xgboost
這是最簡(jiǎn)潔的解決辦法,當(dāng)然也可以install from source华坦,此處不做介紹昆咽。
上面的辦法應(yīng)該可以解決大多數(shù)人的問題,但是我還遇到一點(diǎn)小麻煩忧换。brew install gcc@5
時(shí)發(fā)現(xiàn)下面的問題
Error: The
brew link
step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink share/man/man7/fsf-funding-5.7
/usr/local/share/man/man7 is not writable.
此處涉及brew permission的問題,尋找Brew Troubleshooting解決
If commands fail with permissions errors, check the permissions of /usr/local’s subdirectories. If you’re unsure what to do, you can run cd /usr/local && sudo chown -R $(whoami) bin etc include lib sbin share var Frameworks.