Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I install XGBoost package in python on Windows

Tags:

python

xgboost

I tried to install XGBoost package in python. I am using windows os, 64bits . I have gone through following.

The package directory states that xgboost is unstable for windows and is disabled: pip installation on windows is currently disabled for further invesigation, please install from github. https://pypi.python.org/pypi/xgboost/

I am not well versed in Visual Studio, facing problem building XGBoost. I am missing opportunities to utilize xgboost package in data science.

Please guide, so that I can import the XGBoost package in python.

Thanks

like image 563
shan Avatar asked Feb 19 '16 16:02

shan


3 Answers

If you are using anaconda (or miniconda) you can use the following:

  • conda install -c anaconda py-xgboost UPDATED 2019-09-20
  • Docs
  • Other channels available, such as rapidsai/py-xgboost UPDATED 2021-12-07

Check install by:

  • Activating the environment (see below)
  • Running conda list

To activate an environment:

On Windows, in your Anaconda Prompt, run (assumes your environment is named myenv):

  • activate myenv

On macOS and Linux, in your Terminal Window, run (assumes your environment is named myenv):

  • source activate myenv

Conda prepends the path name myenv onto your system command.

like image 63
Adrian Torrie Avatar answered Nov 14 '22 21:11

Adrian Torrie


Build it from here:

  • download xgboost whl file from here (make sure to match your python version and system architecture, e.g. "xgboost-0.6-cp35-cp35m-win_amd64.whl" for python 3.5 on 64-bit machine)
  • open command prompt
  • cd to your Downloads folder (or wherever you saved the whl file) pip install xgboost-0.6-cp35-cp35m-win_amd64.whl (or whatever your whl file is named)
like image 44
Prateek_Nepaliya Avatar answered Nov 14 '22 20:11

Prateek_Nepaliya


You first need to build the library through "make", then you can install using anaconda prompt (if you want it on anaconda) or git bash (if you use it in Python only).

First follow the official guide with the following procedure (in Git Bash on Windows):

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

then install TDM-GCC here and do the following in Git Bash:

alias make='mingw32-make'
cp make/mingw64.mk config.mk; make -j4

Last, do the following using anaconda prompt or Git Bash:

cd xgboost\python-package  
python setup.py install 

Also refer to these great resources:

Official Guide

Installing Xgboost on Windows

Installing XGBoost For Anaconda on Windows

like image 4
George Liu Avatar answered Nov 14 '22 21:11

George Liu