Windows xgboost error

2019-07-14 20:08发布

问题:

It was a pain just to install xgboost library, but now other mistake happened on Windows 8.1 64-bit

import xgboost as xgb

Traceback (most recent call last):
  File "C:/Users/Пашка/PycharmProjects/kaggler bank santander/1.py", line 12, in <module>
    import xgboost as xgb
  File "C:\Python34\lib\site-packages\xgboost-0.4-py3.4.egg\xgboost\__init__.py", line 11, in <module>
    from .core import DMatrix, Booster
  File "C:\Python34\lib\site-packages\xgboost-0.4-py3.4.egg\xgboost\core.py", line 83, in <module>
    _LIB = _load_lib()
  File "C:\Python34\lib\site-packages\xgboost-0.4-py3.4.egg\xgboost\core.py", line 77, in _load_lib
    lib = ctypes.cdll.LoadLibrary(lib_path[0])
  File "C:\Python34\lib\ctypes\__init__.py", line 429, in LoadLibrary
    return self._dlltype(name)
  File "C:\Python34\lib\ctypes\__init__.py", line 351, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application

What can be done? I think it is because of how .py files associated in Windows I guess

回答1:

I think that probably the simplest (most painless) way to install xgboost can be found here:

https://dnc1994.com/2016/03/installing-xgboost-on-windows/ (Much thanks to the author!)

I downloaded TDM-GCC as recommended by the author prior to following their instructions.

Also, I had similar issues installing xgboost on 32-bit Python but am having no issues using 64-bit Python.

Note: I'm running Python 2.7 on Windows 7.



回答2:

Building on Windows has recently become much simpler:

Install CMake

CMake can be downloaded from here: https://cmake.org/download/

I downloaded the 64 bit zip file: https://cmake.org/files/v3.6/cmake-3.6.2-win64-x64.zip and unzipped it to c:\dev\cmake-3.6.2-win64-x64.

Build XGBoost

To build XGBoost follow these steps:

  • git clone https://github.com/dmlc/xgboost.git
  • cd xgboost
  • git submodule init
  • git submodule update
  • mkdir build
  • cd build
  • C:\dev\cmake-3.6.2-win64-x64\bin\cmake.exe .. -G”Visual Studio 14 2015 * Win64″
  • C:\Program Files (x86)\MSBuild\14.0\Bin\msbuild.exe /t:Clean,Rebuild /p:Configuration=Release xgboost.sln

Or Just Download the Binaries (x64)

Unofficial (mine) Nightly builds here.