python 安装xgboost_如何在MacOS上的python中安装xgboost?

I am a newbie and learning python. Can someone help me- how to install xgboost in python. Im using Mac 10.11. I read online and did the below mentioned step, but not able to decode what to do next:

pip install xgboost -

解决方案

It's a little more complicated if you want to use multi-threading. For the record, I am using a Mac with OS X 10.10 (Yosemite). It took me a while to work through the various issues, but it is now running nicely in my Anaconda (Py36) environment.

For multi-threading you need to do the following first (install homebrew if you have not done so):

brew install gcc --without-multilib

You might get some warnings to unlink directories or delete them if you have other versions installed; follow the warnings/instructions.

Next get the xgboost files from Github. I downloaded it to Anaconda/pkgs directory.

git clone --recursive https://github.com/dmlc/xgboost

The next series of steps differ from the documentation on the xgboost site, and I cobbled it together from lots of sources and also experimenting. The problem is that some key lines in the make files are commented out and also not fully specified.

cd xgboost; cp make/config.mk ./config.mk

Now, use your favorite editor (I used vi), and go into the file that you copied from /make to /xgboost

vi config.mk

Uncomment the lines near the top of the file:

export CC = gcc

export CXX = g++

Change them to the following:

export CC = gcc-6

export CXX = g++-6

It is possible that simply uncommenting the lines solves the problem. It did not for me; I needed to add the -6 to both lines. Save the file.

Also, make changes to the file xgboost/Makefile; change lines:

export CC = $(if $(shell which clang), clang, gcc)

...

...

export CXX = $(if $(shell which clang++), clang++, g++)

to the following:

export CC = $(if $(shell which clang), clang, gcc-6)

...

...

export CXX = $(if $(shell which clang++), clang++, g++-6)

Again, I used vi for this editing.

Save the file and now you need to run a cleaning step since you changed the Makefile.

make clean_all && make -j4

This should configure it cleanly and build the library. You still need to install it.

cd python-package; python setup.py install

Now restart Python/Anaconda and you should be able to import the library.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值