Xgboost installation error in anaconda windows 8

Hello Friends,

I tried multiple solutions from different sites but unable to import the XGBoost in Spyder-anaconda base environment. Seeing below error. Most solutions are pointing to the below website to download the xgboost.dll or similar one but it is not available now.

Any help appreciated.:

import xgboost
Traceback (most recent call last):

  File "<ipython-input-2-e528dc1a32ff>", line 1, in <module>
    import xgboost

  File "C:\Users\praveen\Anaconda3\Lib\site-packages\xgboost\__init__.py", line 11, in <module>
    from .core import DMatrix, Booster

  File "C:\Users\praveen\Anaconda3\Lib\site-packages\xgboost\core.py", line 161, in <module>
    _LIB = _load_lib()

  File "C:\Users\praveen\Anaconda3\Lib\site-packages\xgboost\core.py", line 123, in _load_lib
    lib_paths = find_lib_path()

  File "C:\Users\praveen\Anaconda3\Lib\site-packages\xgboost\libpath.py", line 52, 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\praveen\Anaconda3\envs\PythonCPU\Library\mingw-w64\bin\xgboost.dll
C:\Users\praveen\Anaconda3\Lib\site-packages\xgboost\../../windows/x64/Release/xgboost.dll
C:\Users\praveen\Anaconda3\Lib\site-packages\xgboost\./windows/x64/Release/xgboost.dll

Thanks!!

Did you try pip install xgboost? There is no longer a need to separately procure xgboost.dll.

Thanks for your response, @hcho3. Below is the result when the given pip command is executed:

(base) C:\Users\praveen>pip install xgboost
Requirement already satisfied: xgboost in c:\users\praveen\anaconda3\lib\site-pa
ckages (0.90)
Requirement already satisfied: scipy in c:\users\praveen\anaconda3\lib\site-pack
ages (from xgboost) (1.5.2)
Requirement already satisfied: numpy in c:\users\praveen\anaconda3\lib\site-pack
ages (from xgboost) (1.19.1)

(base) C:\Users\praveen> 

After this, restarted the Anaconda and tried importing XGBoost but seeing the same error.

It looks like you have a broken installation of xgboost. Try re-installing it by

pip uninstall xgboost
pip install xgboost

1 Like

Thanks. It fixed after uninstalling and installing the xgboost package.