xgboost python 在windows下安装

来源:互联网 发布:巫师3和老滚5 知乎 编辑:程序博客网 时间:2024/06/06 01:17

参考官方文档安装明:https://xgboost.readthedocs.io/en/latest/build.html#building-on-windows
需要的环境:
已经安装git bash
安装mingw64时,architecture一定要选择 x86_64 而不是默认的 i6.8.6
安装cmake
安装之后都需要添加到环境变量中,cmake可能在安装过程中就可以勾选添加上
使用git bash clone
由于:Important the newest version of xgboost uses submodule to maintain packages. So when you clone the repo, remember to use the recursive option as follows.
所以需要使用 recursive option

将clone下来的文件xgboost保存到D盘根目录

在git bash中首先到D盘

cd D:

在git bash中输入如下指令

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

In MinGW, make command comes with the name mingw32-make. You can add the following line into the .bashrc file.
并没有将 alias make=’mingw32-make’ 加入到.bashrc file,所以make还是用mingw32-make代替
输入

cp make/mingw64.mk config.mk

上面的make还是make
然后输入

mingw32-make -j4

接着输入

mkdir build

提示目录已经存在
所以改为

mkdir build-new

然后

cd build-new
cmake .. -G"Visual Studio 12 2013 Win64"

进入目录build-new
使用visual studio 2013 打开xgboost.sln文件
右键 ALL_BUILD,点“生成”(build)
等完成之后,在之前创建的build-new中的Debug文件夹下,将libxgboost.lib复制到
之前clone下来的xgboost (即是build-new上级目录) 中 python-package\xgboost 目录下
然后cmd打开控制台,cd到clone下来的xgboost\python-package:

cd D:
cd D:\xgboost\python-package

然后

python setup.py install

完成安装,版本0.60
进入python,import xgboost 没有报错

0 0
原创粉丝点击