在Mac上安装Xgboost

时间:2017-06-19 20:50:43

标签: python macos xgboost

我正在尝试在我的mac上安装xgboost(10.12.5),经过几次尝试后我没有成功。我通过添加gcc-6跟随不同的tuto尝试修改gcc变量,但我有同样的问题。

所以我做了什么:

  1. git clone --recursive https://github.com/dmlc/xgboost
  2. cd xgboost; cp make / minimum.mk ./config.mk; make -j4
  3. 我有以下错误:

    /usr/local/bin/g++ -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude   -Idmlc-core/include -Irabit/include -I/include -O3 -funroll-loops -msse2 -fPIC -DDISABLE_OPENMP -MM -MT build/learner.o src/learner.cc >build/learner.d
    /usr/local/bin/g++ -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude   -Idmlc-core/include -Irabit/include -I/include -O3 -funroll-loops -msse2 -fPIC -DDISABLE_OPENMP -MM -MT build/logging.o src/logging.cc >build/logging.d
    /usr/local/bin/g++ -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude   -Idmlc-core/include -Irabit/include -I/include -O3 -funroll-loops -msse2 -fPIC -DDISABLE_OPENMP -MM -MT build/c_api/c_api.o src/c_api/c_api.cc >build/c_api/c_api.d
    /usr/local/bin/g++ -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude   -Idmlc-core/include -Irabit/include -I/include -O3 -funroll-loops -msse2 -fPIC -DDISABLE_OPENMP -MM -MT build/c_api/c_api_error.o src/c_api/c_api_error.cc >build/c_api/c_api_error.d
    /bin/sh: /usr/local/bin/g++: No such file or directory
    /bin/sh: /usr/local/bin/g++: No such file or directory
    make: *** [build/learner.o] Error 127
    make: *** Waiting for unfinished jobs....
    /bin/sh: /usr/local/bin/g++: No such file or directory
    make: *** [build/logging.o] Error 127
    make: *** [build/c_api/c_api.o] Error 127
    /bin/sh: /usr/local/bin/g++: No such file or directory
    make: *** [build/c_api/c_api_error.o] Error 127
    

    我的gcc版本是:

    Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
    Apple LLVM version 8.1.0 (clang-802.0.42)
    Target: x86_64-apple-darwin16.6.0
    Thread model: posix
    InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
    

    我真的需要你的帮助。目前我使用pip install xgboost来使用库,但我知道这不是使用此库的正确方法。 谢谢你的帮助

    ps:对不起,如果我的英语不好,我就不会流利

3 个答案:

答案 0 :(得分:0)

使用Docker镜像可以在这种情况下发挥最佳效果,因为它封装了环境。您可以从here安装Docker。如果要使用xgboost库,可以使用以下命令

来提取图像
docker pull datmo/xgboost:cpu

在此之后,您可以使用此映像运行容器并装入必要的文件以运行相同的环境。

您还可以使用datmo CLI轻松设置环境,并对机器学习模型进行版本控制。

答案 1 :(得分:0)

我可以使用conda在我的Mac上安装xgboost。

尝试“ conda安装py-xgboost”。这对我有用。

答案 2 :(得分:0)

尝试使用此方法

$ brew install gcc-5
$ brew install cmake
$ pip install xgboost