Windowsへのxgboostインストール


環境:Windows7

発生事象：pip install xgboostを実行してもインストールできない
$ pip install xgboost
Collecting xgboost
  Using cached xgboost-0.6a2.tar.gz
No files/directories in C:\Users\xxxx\AppData\Local\Temp\pip-build-eu18wscp\                                                                            xgboost\pip-egg-info (from PKG-INFO)

上記をふまえ、ちゃんと調べないといけないと思い、調査開始。
まず、以下のURLを参照。
http://www.picnet.com.au/blogs/guido/post/2016/09/22/xgboost-windows-x64-binaries-for-download/

以下の手順をふむ事でインストール可能な模様。
1.git clone https://github.com/dmlc/xgboost.git xgboost_install_dir
2.copy libxgboost.dll (downloaded from this page) into the xgboost_install_dir\python-package\xgboost\directory
3.cd xgboost_install_dir\python-package\
4.python setup.py install

まず、
1.の手順を実施。インストールディレクトリはカレントディレクトリを指定するので、割愛。
git clone https://github.com/dmlc/xgboost.git
以下、出力結果。問題なく完了した模様。
Cloning into 'xgboost'...
remote: Counting objects: 21671, done.
remote: Compressing objects: 100% (28/28), done.
remote: Total 21671 (delta 2), reused 7 (delta 1), pack-reused 21642
Receiving objects: 100% (21671/21671), 7.69 MiB | 1.48 MiB/s, done.
Resolving deltas: 100% (12772/12772), done.

2.の手順を実施すべく、参照したURLからlibxgboost.dllをローカルPCにダウンロード。
DOSではなくてもよいので、マニュアルでカレントディレクトリ配下にコピー。
xgboost\python-package\xgboost\

3.の手順を実施し、カレントディレクトリを移動。
cd xgboost_install_dir\python-package\

4.の手順を実施し、インストールを試みるもエラー発生
$ python setup.py install
Traceback (most recent call last):
  File "setup.py", line 19, in <module>
    LIB_PATH = [os.path.relpath(libfile, CURRENT_DIR) for libfile in libpath['find_lib_path']()]
  File "xgboost/libpath.py", line 49, in find_lib_path
    'List of candidates:\n' + ('\n'.join(dll_path)))
XGBoostLibraryNotFound: Cannot find XGBoost Library in the candidate path, did you install compilers and run build.sh in root path?
List of candidates:
C:\Users\xxxxxxxx\xgboost\python-package\xgboost\xgboost.dll
C:\Users\xxxxxxxx\xgboost\python-package\xgboost\../../lib/xgboost.dll
C:\Users\xxxxxxxx\xgboost\python-package\xgboost\./lib/xgboost.dll
C:\Users\xxxxxxxx\AppData\Local\Continuum\Anaconda3\xgboost\xgboost.dll
C:\Users\xxxxxxxx\xgboost\python-package\xgboost\../../windows/x64/Release/xgboost.dll
C:\Users\xxxxxxxx\xgboost\python-package\xgboost\./windows/x64/Release/xgboost.dll

エラーの内容から、xgboost.dllがない事でエラーになっている模様。
試しにlibxgboost.dllをxgboost.dllにリネームして実施したところ、正常終了。
$ python setup.py install
Install libxgboost from: ['xgboost\\xgboost.dll']
running install
running bdist_egg
running egg_info
creating xgboost.egg-info
writing xgboost.egg-info\PKG-INFO
writing dependency_links to xgboost.egg-info\dependency_links.txt
writing requirements to xgboost.egg-info\requires.txt
writing top-level names to xgboost.egg-info\top_level.txt
writing manifest file 'xgboost.egg-info\SOURCES.txt'
reading manifest file 'xgboost.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '*' under directory 'xgboost\include'
warning: no files found matching '*' under directory 'xgboost\src'
warning: no files found matching '*' under directory 'xgboost\make'
warning: no files found matching '*' under directory 'xgboost\rabit'
warning: no files found matching '*' under directory 'xgboost\lib'
warning: no files found matching '*' under directory 'xgboost\dmlc-core'
warning: no previously-included files matching '*.o' found anywhere in distribution
warning: no previously-included files matching '*.a' found anywhere in distribution
warning: no previously-included files matching '*.pyo' found anywhere in distribution
warning: no previously-included files matching '*.pyc' found anywhere in distribution
writing manifest file 'xgboost.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
creating build
creating build\lib
creating build\lib\xgboost
copying xgboost\callback.py -> build\lib\xgboost
copying xgboost\compat.py -> build\lib\xgboost
copying xgboost\core.py -> build\lib\xgboost
copying xgboost\libpath.py -> build\lib\xgboost
copying xgboost\plotting.py -> build\lib\xgboost
copying xgboost\rabit.py -> build\lib\xgboost
copying xgboost\sklearn.py -> build\lib\xgboost
copying xgboost\training.py -> build\lib\xgboost
copying xgboost\__init__.py -> build\lib\xgboost
copying xgboost\VERSION -> build\lib\xgboost
copying xgboost\build-python.sh -> build\lib\xgboost
copying xgboost\xgboost.dll -> build\lib\xgboost
creating build\bdist.win-amd64
creating build\bdist.win-amd64\egg
creating build\bdist.win-amd64\egg\xgboost
copying build\lib\xgboost\build-python.sh -> build\bdist.win-amd64\egg\xgboost
copying build\lib\xgboost\callback.py -> build\bdist.win-amd64\egg\xgboost
copying build\lib\xgboost\compat.py -> build\bdist.win-amd64\egg\xgboost
copying build\lib\xgboost\core.py -> build\bdist.win-amd64\egg\xgboost
copying build\lib\xgboost\libpath.py -> build\bdist.win-amd64\egg\xgboost
copying build\lib\xgboost\plotting.py -> build\bdist.win-amd64\egg\xgboost
copying build\lib\xgboost\rabit.py -> build\bdist.win-amd64\egg\xgboost
copying build\lib\xgboost\sklearn.py -> build\bdist.win-amd64\egg\xgboost
copying build\lib\xgboost\training.py -> build\bdist.win-amd64\egg\xgboost
copying build\lib\xgboost\VERSION -> build\bdist.win-amd64\egg\xgboost
copying build\lib\xgboost\xgboost.dll -> build\bdist.win-amd64\egg\xgboost
copying build\lib\xgboost\__init__.py -> build\bdist.win-amd64\egg\xgboost
byte-compiling build\bdist.win-amd64\egg\xgboost\callback.py to callback.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\xgboost\compat.py to compat.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\xgboost\core.py to core.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\xgboost\libpath.py to libpath.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\xgboost\plotting.py to plotting.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\xgboost\rabit.py to rabit.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\xgboost\sklearn.py to sklearn.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\xgboost\training.py to training.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\xgboost\__init__.py to __init__.cpython-36.pyc
installing package data to build\bdist.win-amd64\egg
running install_data
creating build\bdist.win-amd64\egg\EGG-INFO
copying xgboost.egg-info\PKG-INFO -> build\bdist.win-amd64\egg\EGG-INFO
copying xgboost.egg-info\SOURCES.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying xgboost.egg-info\dependency_links.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying xgboost.egg-info\not-zip-safe -> build\bdist.win-amd64\egg\EGG-INFO
copying xgboost.egg-info\requires.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying xgboost.egg-info\top_level.txt -> build\bdist.win-amd64\egg\EGG-INFO
writing build\bdist.win-amd64\egg\EGG-INFO\native_libs.txt
creating dist
creating 'dist\xgboost-0.6-py3.6.egg' and adding 'build\bdist.win-amd64\egg' to it
removing 'build\bdist.win-amd64\egg' (and everything under it)
Processing xgboost-0.6-py3.6.egg
creating c:\users\xxxxxxxx\appdata\local\continuum\anaconda3\lib\site-packages\xgboost-0.6-py3.6.egg
Extracting xgboost-0.6-py3.6.egg to c:\users\xxxxxxxx\appdata\local\continuum\anaconda3\lib\site-packages
Adding xgboost 0.6 to easy-install.pth file

Installed c:\users\xxxxxxxx\appdata\local\continuum\anaconda3\lib\site-packages\xgboost-0.6-py3.6.egg
Processing dependencies for xgboost==0.6
Searching for scipy==0.19.0
Best match: scipy 0.19.0
Adding scipy 0.19.0 to easy-install.pth file

Using c:\users\xxxxxxxx\appdata\local\continuum\anaconda3\lib\site-packages
Searching for numpy==1.12.1
Best match: numpy 1.12.1
Adding numpy 1.12.1 to easy-install.pth file

Using c:\users\xxxxxxxx\appdata\local\continuum\anaconda3\lib\site-packages
Finished processing dependencies for xgboost==0.6

※追記※
以下のURLを参照
https://github.com/dmlc/xgboost/issues/2674
どうやら以下のコマンドでもインストール可能な模様。
conda install -c anaconda py-xgboost