http://xgboost.readthedocs.org/en/latest/python/python_intro.html
在xgboost的主页(上面的链接)上,它说:要安装XGBoost,请执行以下步骤:
-
您需要在项目的根目录下运行
make
-
在python-package目录下运行
python setup.py install
然而,当我执行时,在第一步出现了以下错误:make : 术语 ‘make’ 未被识别为 cmdlet、函数、脚本文件或可操作程序的名称。请检查名称的拼写,或者如果包含了路径,请验证路径是否正确,然后重试。
然后我跳过了第一步,直接执行了第二步,又出现了另一个错误:
Traceback (most recent call last): File "setup.py", line 19, in <module> LIB_PATH = libpath['find_lib_path']() File "xgboost/libpath.py", line 44, in find_lib_path 'List of candidates:\n' + ('\n'.join(dll_path)))__builtin__.XGBoostLibraryNotFound: 在候选路径中找不到XGBoost库,您是否安装了编译器并在根路径下运行了build.sh?
有谁知道如何在Windows10平台上为Python安装xgboost?感谢您的帮助!
回答:
我在Windows 8 64位,Python 2.7和Visual Studio 2013上成功安装了XGBoost(不需要mingw64)
更新于2017年2月15日
对于较新版本的XGBoost,以下是我的步骤
步骤1. 安装cmake https://cmake.org/download/
验证cmake
是否已成功安装
$ cmakeUsagecmake [options] <path-to-source>cmake [options] <path-to-existing-build>...
步骤2. 克隆xgboost源码
$ git clone https://github.com/dmlc/xgboost xgboost_dir
步骤3. 创建Visual Studio项目
$ cd xgboost_dir$ mkdir build$ cd build$ cmake .. -G"Visual Studio 12 2013 Win64"
步骤4. 构建Visual Studio 2013项目
- 使用Visual Studio 2013打开文件
xgboost_dir/build/ALL_BUILD.vcxproj
- 在Visual Studio 2013中,打开
BUILD > Configuration Manager...
- 在活动解决方案配置中选择Release
- 在活动解决方案平台中选择x64
- 点击BUILD > 构建解决方案(Ctrl + Shift +B)
构建解决方案后,会在xgboost_dir/lib
文件夹中创建两个新文件libxgboost.dll
和xgboost.exe
步骤5. 构建Python包
- 将文件
libxgboost.dll
复制到xgboost_dir/python-package
- 将目录更改为
xgboost_dir/python-package
文件夹 - 运行命令
python setup.py install
验证xgboost是否已成功安装
$ python -c "import xgboost"
旧答案
以下是我的步骤:
- git clone https://github.com/dmlc/xgboost
- git checkout 9bc3d16
- 使用Visual Studio 2013打开
xgboost/windows
中的项目 - 在Visual Studio 2013中,打开
BUILD > Configuration Manager...
,- 在活动解决方案配置中选择
Release
- 在活动解决方案平台中选择
x64
- 在活动解决方案配置中选择
- 重新构建
xgboost
,xgboost_wrapper
- 将
xgboost/windows/x64/Release
文件夹中的所有文件复制到xgboost/wrapper
- 转到
xgboost/python-package
,运行命令python setup.py install
- 通过运行命令
python -c "import xgboost"
检查xgboost