如何在MacOS上的python中安装xgboost? [英] How to install xgboost in python on MacOS?

查看:624
本文介绍了如何在MacOS上的python中安装xgboost?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一名新手,正在学习python.有人可以帮助我-如何在python中安装xgboost.我正在使用Mac 10.11.我在线阅读并进行了以下提到的步骤,但无法解码下一步要做的事情:

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 - 

推荐答案

如果要使用多线程,则要复杂一些.作为记录,我使用的是Mac OS X 10.10(Yosemite).我花了一些时间解决各种问题,但现在在Anaconda(Py36)环境中运行良好.

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.

对于多线程,您需要首先执行以下操作(如果尚未安装homebrew,则应这样做):

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.

接下来,从Github获取xgboost文件.我将其下载到Anaconda/pkgs目录.

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

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

接下来的一系列步骤与xgboost站点上的文档不同,我从许多来源中将其拼凑在一起,并且还进行了实验.问题在于make文件中的某些关键行被注释掉了,并且也没有完全指定.

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

现在,使用您喜欢的编辑器(我使用vi),进入从/make复制到/xgboost

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

只需取消注释行就可以解决问题.它不适合我.我需要将-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.

此外,对文件xgboost/Makefile进行更改;换行:

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++)

到以下:

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

同样,我使用vi进行编辑.

Again, I used vi for this editing.

保存文件,由于更改了Makefile,现在您需要运行清理步骤.

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

现在重新启动Python/Anaconda,您应该可以导入该库了.

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

这篇关于如何在MacOS上的python中安装xgboost?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆