Python anaconda 的 xgboost 安装问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36292484/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
xgboost installation issue with anaconda
提问by wen
I am using Anaconda. I first switched to Python2 (Version 2.7.11).
我正在使用蟒蛇。我首先切换到 Python2(版本 2.7.11)。
python -V
Python 2.7.11 :: Continuum Analytics, Inc.
I used the following command to install xgboost in anaconda.
我使用以下命令在 anaconda 中安装 xgboost。
conda install -c https://conda.anaconda.org/akode xgboost
I then checked that xgboost is installed.
然后我检查了 xgboost 是否已安装。
conda list
xgboost 0.3 py27_0 akode
I run python in terminal, import xgboost and got the following errors.
我在终端中运行 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
I have no idea what to do next.
我不知道接下来要做什么。
回答by Adrien Forbu
The package image you download is corrupt. What you should do :
您下载的软件包映像已损坏。你应该做什么:
First remove your xgboost package with (in the terminal) :
首先使用(在终端中)删除您的 xgboost 包:
conda remove xgboost
康达删除 xgboost
Then reinstall with an other package at https://anaconda.org/aterrel/xgboostSo just write :
然后在https://anaconda.org/aterrel/xgboost用其他包重新安装 所以只需写:
conda install py-xgboost
畅达安装 py-xgboost
Then you can check the installation in the python console :
然后你可以在 python 控制台中检查安装:
import xgboost
导入 xgboost
It should be ok.
应该没问题。
回答by Subhojit Mukherjee
I had the same error. I completely uninstalled xgboost by pip unistall. then installed it back by:
我有同样的错误。我通过 pip unistall 完全卸载了 xgboost。然后通过以下方式安装它:
conda install -c bioconda xgboost=0.6a2
This seems to solve the problem
这似乎解决了问题
回答by George Liu
You first need to build the library through "make", then you can install using anaconda prompt.
您首先需要通过“make”构建库,然后您可以使用 anaconda prompt 进行安装。
First follow the official guide with the following procedure (in Git Bash on Windows):
首先按照以下步骤(在 Windows 上的 Git Bash 中)按照官方指南进行操作:
git clone --recursive https://github.com/dmlc/xgboost
git submodule init
git submodule update
alias make='mingw32-make'
cp make/mingw64.mk config.mk; make -j4
Last, do the following using anaconda prompt:
最后,使用 anaconda 提示符执行以下操作:
cd xgboost\python-package
python setup.py install
Also refer to these great resources:
另请参阅这些重要资源:
回答by jasonHan
Library not loaded: @rpath/./libgomp.1.dylib
库未加载:@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"
就我而言,它是“库未加载:/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 .
我检查了我的路径“/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”没有错误。
回答by S?ren
Did you try using pip?source activate yourenvironment
pip install xgboost
你试过用pip吗?source activate yourenvironment
pip install xgboost
回答by Leonardo Hermoso
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
就我而言,问题是我与普通用户一起安装了 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)
>>> ~
Hope this can help!
希望这可以帮助!
回答by jxlijunhao
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
在我的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