This is What You Should Do If You Fail to Install the Latest or an Older Version of XGBoost on Your Windows Machine

Nurman Naz
Analytics Vidhya
Published in
6 min readFeb 5, 2020

When delivering my data science training session, my students always have difficulties in installing XGBoost package using Anaconda on the Windows machine. Yes, most data scientists would have agreed that Windows OS should never be the number one choice to run your data science projects. However, the bitter truth is that the majority of people (i.e., non-programmers) are still using Microsoft Windows as the primary operating system on their laptops. In fact, most of my students have no or very little Python programming experience.

From my experience, there can be simply too many different types of installation errors that one may encounter when installing XGBoost on Windows. This somewhat has made my first few hours of the first-day training session so unproductive, as I tend to spend more time debugging my students’ installation problems.

Typically, when there is an installation issue, StackOverflow has always been my number one choice to seek for help. Unfortunately, XGBoost has gone through so many major changes in each version update, and therefore it was simply extremely challenging to find a reliable and fast solution even on the StackOverflow or on the official XGBoost forum.

Therefore, in this article, I will discuss some of the installation issues that I typically encounter during my training classes with the students. After discussing the common installations errors that I typically face, I will finally describe a simple solution in which I was able to solve the XGBoost installation problems on most of my students’ Windows machine.

Failed Attempt using the “conda install”

In my class, Anaconda is the primary choice of the toolkit that I normally ask my students to install. This is simply due to the fact that Anaconda provides all the critical data science packages such as jupyter notebook, pandas, scikit-learn, scipy and several others. Therefore, the obvious method to install XGBoost is simply to use the conda install command.

(base) C:\>conda install py-xgboost=0.71

The above command simply tries to download XGBoost package of specific version. In this case, I intend to download and install version 0.71 of XGBoost since I used some code that rely on XGBoost APIs that have now been deprecated by the latest version of XGBoost. Also, most data science code which are available in the github or Kaggle repositories normally have similar issues where you often need to use a specific version of XGBoost in order to get it to compile and run.

Unfortunately, with the conda install command, I encounter the “Solving environment” error multiple times before Conda finally display an error regarding package conflicts with my python installation. It suggested that I should downgrade my Python version of 3.7 to 3.6, which is not really practical for my case.

(base) C:\>conda install py-xgboost==0.71
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: /
Found conflicts! Looking for incompatible packages.
This can take several minutes. Press CTRL-C to abort.
failed

UnsatisfiableError: The following specifications were found |
to be incompatible with the existing python installation in your environment:

Specifications:

- py-xgboost==0.71 -> python[version=’>=3.5,❤.6.0a0|>=3.6,❤.7.0a0']

Your python: python=3.7

If python is on the left-most side of the chain, that’s the version you’ve asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.

The following specifications were found to be incompatible with each other:

Package certifi conflicts for:
py-xgboost==0.71 -> python[version=’>=3.5,❤.6.0a0'] -> pip -> requests -> certifi[version=’>=2016.09|>=2016.9.26|>=2017.4.17']
python=3.7 -> pip -> setuptools -> certifi[version=’>=2016.09|>=2016.9.26']
…..

Failed Attempt On Using the “pip install”

My next attempt was to install XGBoost version 0.71 using pip. The standard way is the following command:

(base) PS C:\aurak\python> pip install xgboost==0.71

Unfortunately, the pip is also unable to install older version of XGBoost. If you run the command with only “XGBoost” without “the==0.71” option, the XGBoost seems to install perfectly though. In some cases, my students are unable to install XGBoost even with just a simple “pip install xgboost” command without the extra option. However, in my case, I need to install the older version of XGBoost (i.e., version 0.71), which the above pip command fails to achieve.

After going through the StackOverflow and the XGBoost official forum, I found that the pip install command does not work well on the Windows platform (see here: https://discuss.xgboost.ai/t/pip-install-xgboost-isnt-working-on-windows-x64/57/2). Therefore, I decided not to explore this method further.

Final Attempt That Actually Works

I solve the issue by simply downloading the actual XGBoost binary that I need from the official PyPi website (i.e., https://pypi.org/) , and place the downloaded XGBoost folders inside my Anaconda installation python packages.

In Anaconda, all the installation python packages are normally stored under a directory which is often named as the site packages. Therefore, one can download the windows binary of the XGBoost version 0.71 and place them within the site-packages. I will explain the steps below.

First, you will need to determine the path of your site-packages directory in Windows directory. To do this, simply run the following code in your Python shell.

(base) PS C:\aurak\python> python
Python 3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from distutils.sysconfig import get_python_lib
>>> print(get_python_lib())
C:\Users\nurman\AppData\Local\Continuum\anaconda3\Lib\site-packages

As can you see above, my site-packages directory is located at the following path: C:\Users\nurman\AppData\Local\Continuum\anaconda3\Lib\site-packages.

Once you found out your own site-packages directory in your Windows machine, it is time to download the XGBoost files from the official pypi.org website. On the official website, type XGBoost as the search keyword. The website will take you to the XGBoost Python package website.

You can observe that at the time of writing, the latest version of XGBoost is 0.90. If you need to find an older version, click on the Release history button.

If you scroll down, you should be able to find the version that you want. In my case, I found the version that I need which is 0.71. Clicking on the link will take me the web page where I can download the XGBoost release as tar.gz file.

Go ahead and download the tar.gz file. Once downloaded, you will need to extract and copy 2 important folders, namely, xgboost and xgboost.egg-info to your site-packages directory.

That’s all. Now, you can verify whether your XGBoost installation is working correctly from the Python shell.

Python 3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import xgboost as xgb
>>> xgb.__version__
‘0.71’

Voila! Your XGBoost installation on the Windows machine has been successfully completed. Well done.

--

--