【问题标题】:xgboost installation issue with anacondaanaconda 的 xgboost 安装问题
【发布时间】:2016-07-17 11:47:56
【问题描述】:

我正在使用 Anaconda。我首先切换到 Python2(版本 2.7.11)。

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

我使用以下命令在 anaconda 中安装 xgboost。

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

然后我检查了 xgboost 是否已安装。

conda list
xgboost                   0.3                      py27_0    akode

我在终端中运行 python,导入 xgboost 并得到以下错误。

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

我不知道下一步该做什么。

【问题讨论】:

    标签: python installation anaconda xgboost


    【解决方案1】:

    库未加载:@rpath/./libgomp.1.dylib

    这是关键。

    在我的情况下,它是“未加载库:/usr/local/opt/gcc/lib/gcc/6/libgomp.1.dylib”

    我检查我的路径“/usr/local/opt/gcc/lib/gcc” 那里只有一个名为 7 的文件夹,没有 6。
    所以我使用“sudo find / -name libgomp.1.dylib”来定位我安装的所有gcc版本,我发现另一个位置有一个版本6。
    然后我在 '/usr/local/opt/gcc/lib/gcc' 下创建一个名为 6 的文件夹,并将这些 gcc 6 文件复制到其中。 最后,“import xgboost”可以正常工作。

    【讨论】:

      【解决方案2】:

      您下载的软件包映像已损坏。 你应该怎么做:

      首先使用(在终端中)删除您的 xgboost 包:

      conda 移除 xgboost

      然后使用https://anaconda.org/aterrel/xgboost 的其他软件包重新安装 所以就写吧:

      conda 安装 py-xgboost

      然后就可以在python控制台查看安装了:

      导入 xgboost

      应该没问题。

      【讨论】:

      • 看起来会安装过期的 xgboost 以及 sklearn 版本 0.16.1(过期)
      • 这对我不起作用。我的 python 版本是 3.5.2,我得到的错误是: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 &lt;package&gt;" to see the dependencies for each package.
      • 好吧,你现在应该做的只是conda install py-xgboost,因为 0.4.0 是旧版本的 xgboost
      【解决方案3】:

      我有同样的错误。我通过 pip unistall 完全卸载了 xgboost。然后通过以下方式将其安装回来:

      conda install -c bioconda xgboost=0.6a2
      

      这似乎解决了问题

      【讨论】:

      • 谢谢,您的建议对我有用。你知道你命令中的bioconda是什么意思吗?
      【解决方案4】:

      在我的 ubuntu 14.04 中,
      首先:安装anaconda
      第二:git clone xgboost,并制作安装,编译python包
      第三:使用 anaconda 设置 xgboost。例如:
      1) cd yourpath/xgboost/python-package
      2) 找到你 anaconda python python 路径:
      anaconda/bin/python setup.py install

      【讨论】:

        【解决方案5】:

        我也遇到过类似的问题

        >>> 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)
        

        就我而言,问题是我使用普通用户安装了 xgboost。所以我做到了

        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)
        >>> ~
        

        希望这能有所帮助!

        【讨论】:

          【解决方案6】:

          你首先需要通过“make”来构建库,然后你可以使用anaconda提示安装。

          首先按照官方指南执行以下步骤(在 Windows 上的 Git Bash 中):

          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
          

          最后,使用 anaconda 提示符执行以下操作:

          cd xgboost\python-package  
          python setup.py install 
          

          还可以参考这些优秀的资源:

          Official Guide

          Installing Xgboost on Windows

          Installing XGBoost For Anaconda on Windows

          【讨论】:

            【解决方案7】:

            您尝试过使用 pip 吗?
            source activate yourenvironment
            pip install xgboost

            【讨论】:

              猜你喜欢
              • 2018-10-29
              • 1970-01-01
              • 2016-08-26
              • 1970-01-01
              • 2016-09-11
              • 1970-01-01
              • 1970-01-01
              • 2018-06-15
              • 2019-01-15
              相关资源
              最近更新 更多