How to install xgboost package in python (windows

2019-01-04 23:05发布

http://xgboost.readthedocs.org/en/latest/python/python_intro.html

On the homepage of xgboost(above link), it says: To install XGBoost, do the following steps:

  1. You need to run make in the root directory of the project

  2. In the python-package directory run

    python setup.py install

However, when I did it, for step 1 the following error appear: make : The term 'make' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

then I skip step1 and did step 2 directly, another error appear:

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: Cannot find XGBoost Libarary in the candicate path, did you install compilers and run build.sh in root path?

Does anyone know how to install xgboost for python on Windows10 platform? Thanks for your help!

17条回答
冷血范
2楼-- · 2019-01-04 23:16

It took a whole day, but I successfully installed xgboost on windows 7 64-bit box using TDM-GCC with OpenMP enabled, instead of MingW following this link - http://dnc1994.com/2016/03/installing-xgboost-on-windows/

查看更多
Luminary・发光体
3楼-- · 2019-01-04 23:19

Thanks to disco4ever answer. I was trying to build xgboost for Python Anaconda environment in my windows 10 64 bit machine. Used Git, mingw64 and basic windows cmd.

Everthing worked for me till the copy step: cp make/mingw64.mk config.mk, as I was using windows cmd I modified it to copy c:\xgboost\make\mingw64.mk c:\xgboost\config.mk

when I proceeded to the next step : make -j4, I got error that build failed. At this stage after so much frustration just tired something different by clicking on build.sh (shell script). It started executing and auto finished.

Then I executed the same step make -j4, to my awe build was successful. I have seen the most awaited xgboost.exe file in my xgboost folder.

I then proceeded with further steps and executed python setup.py install. finally everything installed perfectly. Then I went to my spyder and checked whether it is working or not. But I was one step away to my happiness because I was still seeing the import error.

Closed all command prompts (Anaconda, Git bash, Windows CMD, cygwin terminal) then again opened spyder and typed 'import xgboost'. SUCCESS, No ERROR.

Once again thank you for everyone.

查看更多
淡お忘
4楼-- · 2019-01-04 23:19

Note that: before "make -j4" use gcc -v to check your gcc version.

As to me, My environment is win10 + anaconda(python 2.7), when I run make -j4. It shows std::mutex error. After I use gcc- v It echo gcc4.7(anaconda's default gcc).After I choose my gcc to mingw64's 6.2 gcc ,then it works.

Finally, I use "/d/Anaconda2/python.exe setup.py install" install xgboost python packet.

查看更多
爷、活的狠高调
5楼-- · 2019-01-04 23:20

I installed XGBoost successfully in Windows 8 64bit, Python 2.7 with Visual Studio 2013 (don't need mingw64)

Updated 15/02/2017

With newer version of XGBoost, here are my steps

Step 1. Install cmake https://cmake.org/download/

Verify cmake have been installed successfully

$ cmake
Usage

cmake [options] <path-to-source>
cmake [options] <path-to-existing-build>
...

Step 2. Clone xgboost source

$ git clone https://github.com/dmlc/xgboost xgboost_dir

Step 3. Create Visual Studio Project

$ cd xgboost_dir
$ mkdir build
$ cd build
$ cmake .. -G"Visual Studio 12 2013 Win64"

Step 4. Build Visual Studio 2013 project

  • Open file xgboost_dir/build/ALL_BUILD.vcxproj with Visual Studio 2013
  • In Visual Studio 2013, open BUILD > Configuration Manager...
    • choose Release in Active solution configuration
    • choose x64 in Active solution platform
  • Click BUILD > Build Solution (Ctrl + Shift +B)

After build solution, two new files libxgboost.dll and xgboost.exe are created in folder xgboost_dir/lib

Step 5. Build python package

  • Copy file libxgboost.dll to xgboost_dir/python-package
  • Change directory to xgboost_dir/python-package folder
  • Run command python setup.py install

Verify xgboost have been installed successfully

$ python -c "import xgboost"

Old Answer

Here are my steps:

  1. git clone https://github.com/dmlc/xgboost
  2. git checkout 9bc3d16
  3. Open project in xgboost/windows with Visual Studio 2013
  4. In Visual Studio 2013, open BUILD > Configuration Manager...,
    • choose Release in Active solution configuration
    • choose x64 in Active solution platform
  5. Rebuild xgboost, xgboost_wrapper
  6. Copy all file in xgboost/windows/x64/Release folder to xgboost/wrapper
  7. Go to xgboost/python-package, run command python setup.py install
  8. Check xgboost by running command python -c "import xgboost"
查看更多
老娘就宠你
6楼-- · 2019-01-04 23:22

I followed the steps listed in https://www.kaggle.com/c/otto-group-product-classification-challenge/forums/t/13043/run-xgboost-from-windows-and-python. I will summarize what I did below.

1) Download Visual Basic Studio. You can download the community edition at visual studio website. There is a "free visual studio button on the upper right corner"

2) Copy all content from the git hub repository of xgboost/tree/master/windows and Open Visual studio existing project on Visual studio

3) There are a couple of drop down menus you need to select ( "Release" and "X64" and then select build --> build all from the upper menu. It should look something like the attached screenshot.

4) if you see the message ========== Build: 3 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========, it is all good

5) Browse to python-packages folder where the setup file for XGB resides and run the install command 'python setup.py install'.

You can find a similar thread at Install xgboost under python with 32-bit msys failing

Hope this helps.

查看更多
做自己的国王
7楼-- · 2019-01-04 23:22

To add to the solution by Disco4ever for those attempting to build on 32bit Windows machines.

After doing step 6 and creating a config.mk file you need to go into this file and edit the following lines to remove the -m64 flag

export CXX=g++ -m64
export CC=gcc -m64
查看更多
登录 后发表回答