MacOS上安装xgboost

第一步、尝试pip install xgboost

MacBook-Pro:~/jupyter_local/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
    clang-omp++ -std=c++0x -Wall -O3 -msse2  -Wno-unknown-pragmas -funroll-loops -Iinclude   -Idmlc-core/include -Irabit/include -fPIC -fopenmp -MM -MT build/learner.o src/learner.cc >build/learner.d
    /bin/sh: clang-omp++: command not found
    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
    make: *** [build/learner.o] Error 127
    make: *** Waiting for unfinished jobs....
    /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
    clang-omp++ -std=c++0x -Wall -O3 -msse2  -Wno-unknown-pragmas -funroll-loops -Iinclude   -Idmlc-core/include -Irabit/include -fPIC -fopenmp -MM -MT build/learner.o src/learner.cc >build/learner.d
    /bin/sh: clang-omp++: command not found
    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
    Successfully build single-thread xgboost
    If you want multi-threaded version
    See additional instructions in doc/build.md
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/rz/h1wlyyzx5_53hdlg7lpk2bwc0000gn/T/pip-build-CbVSFW/xgboost/setup.py", line 29, in <module>
        LIB_PATH = libpath['find_lib_path']()
      File "/private/var/folders/rz/h1wlyyzx5_53hdlg7lpk2bwc0000gn/T/pip-build-CbVSFW/xgboost/xgboost/libpath.py", line 45, in find_lib_path
        'List of candidates:\n' + ('\n'.join(dll_path)))
    __builtin__.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/rz/h1wlyyzx5_53hdlg7lpk2bwc0000gn/T/pip-build-CbVSFW/xgboost/xgboost/libxgboost.so
    /private/var/folders/rz/h1wlyyzx5_53hdlg7lpk2bwc0000gn/T/pip-build-CbVSFW/xgboost/xgboost/../../lib/libxgboost.so
    /private/var/folders/rz/h1wlyyzx5_53hdlg7lpk2bwc0000gn/T/pip-build-CbVSFW/xgboost/xgboost/./lib/libxgboost.so

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/rz/h1wlyyzx5_53hdlg7lpk2bwc0000gn/T/pip-build-CbVSFW/xgboost/

报错!

第二步、尝试conda安装

MacBook-Pro:~/jupyter_local/xgboost$ conda install xgboost

Fetching package metadata .........

PackageNotFoundError: Package missing in current osx-64 channels:
  - xgboost

Close matches found; did you mean one of these?

    xgboost: r-xgboost, boost, py-xgboost

第三步、尝试conda install py-xgboost

MacBook-Pro:~/jupyter_local/xgboost$ conda install py-xgboost

Fetching package metadata .........
Solving package specifications: .

Package plan for installation in environment /Users/terrence/anaconda:

The following NEW packages will be INSTALLED:

    libgcc:     4.8.5-1
    libxgboost: 0.60-h8fd8b8a_0
    py-xgboost: 0.60-py27np112hf8e804c_0

The following packages will be UPDATED:

    conda:      4.3.21-py27_0            --> 4.3.25-py27_0

Proceed ([y]/n)? y

libgcc-4.8.5-1 100% |#####################################################################################################################################| Time: 0:00:01 616.78 kB/s
libxgboost-0.6 100% |#####################################################################################################################################| Time: 0:00:02 752.48 kB/s
py-xgboost-0.6 100% |#####################################################################################################################################| Time: 0:00:00 570.01 kB/s
conda-4.3.25-p 100% |#####################################################################################################################################| Time: 0:00:00 522.97 kB/s

测试,安装成功!


比较常规的方法是
参考xgboost官网

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容