14

I am using Anaconda. I first switched to Python2 (Version 2.7.11).

python -V
Python 2.7.11 :: Continuum Analytics, Inc.

I used the following command to install xgboost in anaconda.

conda install -c https://conda.anaconda.org/akode xgboost

I then checked that xgboost is installed.

conda list
xgboost                   0.3                      py27_0    akode

I run python in terminal, import xgboost and got the following errors.

import xgboost as xgb

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "//anaconda/envs/wen2/lib/python2.7/site-packages/xgboost.py", line 82, in <module>
    xglib = load_xglib()
  File "//anaconda/envs/wen2/lib/python2.7/site-packages/xgboost.py", line 59, in load_xglib
    lib = ctypes.cdll.LoadLibrary(lib_path[0])
  File "//anaconda/envs/wen2/lib/python2.7/ctypes/__init__.py", line 443, in LoadLibrary
    return self._dlltype(name)
  File "//anaconda/envs/wen2/lib/python2.7/ctypes/__init__.py", line 365, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(//anaconda/envs/wen2/lib/python2.7/site-packages/libxgboostwrapper.so, 6): Library not loaded: @rpath/./libgomp.1.dylib
  Referenced from: //anaconda/envs/wen2/lib/python2.7/site-packages/libxgboostwrapper.so
  Reason: image not found

I have no idea what to do next.

halfer
  • 19,824
  • 17
  • 99
  • 186
wen
  • 1,875
  • 4
  • 26
  • 43

7 Answers7

19

The package image you download is corrupt. What you should do :

First remove your xgboost package with (in the terminal) :

conda remove xgboost

Then reinstall with an other package at https://anaconda.org/aterrel/xgboost So just write :

conda install py-xgboost

Then you can check the installation in the python console :

import xgboost

It should be ok.

Adrien Forbu
  • 483
  • 4
  • 18
  • looks like that would install xgboost which is out of date, along with sklearn version 0.16.1 (out of date) – avloss Dec 10 '16 at 04:38
  • 1
    This did not work for me. My python version is 3.5.2 and the error I get is : `bash-4.3$ python -V Python 3.5.2 :: Anaconda 4.2.0 (x86_64) (/Users/xxx/anaconda) bash-4.3$ conda install -c aterrel xgboost Fetching package metadata ......... Solving package specifications: .... UnsatisfiableError: The following specifications were found to be in conflict: - python 3.5* - xgboost Use "conda info " to see the dependencies for each package. ` – Taposh DuttaRoy Jan 18 '17 at 01:05
  • 1
    Ok what you should do now is just `conda install py-xgboost` as 0.4.0 is an old version of xgboost – Adrien Forbu Jun 12 '17 at 11:21
5

I had the same error. I completely uninstalled xgboost by pip unistall. then installed it back by:

conda install -c bioconda xgboost=0.6a2

This seems to solve the problem

Tom
  • 4,257
  • 6
  • 33
  • 49
Subhojit Mukherjee
  • 1,355
  • 1
  • 9
  • 2
3

You first need to build the library through "make", then you can install using anaconda prompt.

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

install TDM-GCC here

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

Last, do the following using anaconda prompt:

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

George Liu
  • 3,601
  • 10
  • 43
  • 69
1

Did you try using pip?
source activate yourenvironment
pip install xgboost

Soerendip
  • 7,684
  • 15
  • 61
  • 128
1

Library not loaded: @rpath/./libgomp.1.dylib

This is the key.

In my case, it is " Library not loaded: /usr/local/opt/gcc/lib/gcc/6/libgomp.1.dylib"

I check my path "/usr/local/opt/gcc/lib/gcc" and there is only a folder named 7 there , no 6.
So i use "sudo find / -name libgomp.1.dylib" to locate all the gcc version i have installed, with I found that there is a version 6 in another location.
Then I create a folder named 6 under '/usr/local/opt/gcc/lib/gcc' and copy those gcc 6 files in there . Finally , "import xgboost" works with no error .

jasonHan
  • 11
  • 2
0

I had a similar problem

>>> import xgboost
/usr/local/anaconda2/lib/python2.7/site-packages/sklearn/cross_validation.py:44: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.
  "This module will be removed in 0.20.", DeprecationWarning)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/anaconda2/lib/python2.7/site-packages/xgboost/__init__.py", line 11, in <module>
    from .core import DMatrix, Booster
  File "/usr/local/anaconda2/lib/python2.7/site-packages/xgboost/core.py", line 112, in <module>
    _LIB = _load_lib()
  File "/usr/local/anaconda2/lib/python2.7/site-packages/xgboost/core.py", line 106, in _load_lib
    lib = ctypes.cdll.LoadLibrary(lib_path[0])
  File "/usr/local/anaconda2/lib/python2.7/ctypes/__init__.py", line 440, in LoadLibrary
    return self._dlltype(name)
  File "/usr/local/anaconda2/lib/python2.7/ctypes/__init__.py", line 362, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /usr/local/anaconda2/bin/../lib/libgomp.so.1: version `GOMP_4.0' not found (required by /usr/local/anaconda2/lib/python2.7/site-packages/xgboost/./lib/libxgboost.so)

In my case the problem is that i installed xgboost with a regular user. So i did

sudo su
pip uninstall xgboost
pip install xgboost
python
>>> import xgboost
/usr/local/anaconda2/lib/python2.7/site-packages/sklearn/cross_validation.py:44: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.
  "This module will be removed in 0.20.", DeprecationWarning)
>>> ~

Hope this can help!

Leonardo Hermoso
  • 838
  • 12
  • 26
0

in the my ubuntu 14.04,
first: install anaconda
second: git clone the xgboost, and make and install, complie the python package
third: setup the xgboost with anaconda. for example:
1) cd yourpath/xgboost/python-package
2) find you anaconda python python path:
anaconda/bin/python setup.py install