Python XGBoostLibraryNotFound:在候选路径中找不到XGBoost库,您是否安装了编译器并在根路径中运行了build.sh?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43327020/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 22:52:44  来源:igfitidea点击:

XGBoostLibraryNotFound: Cannot find XGBoost Library in the candidate path, did you install compilers and run build.sh in root path?

pythonanacondaxgboost

提问by Ann

I am facing this problem while moving the python-package directory of XGBoost.

我在移动 XGBoost 的 python-package 目录时遇到了这个问题。

Traceback (most recent call last): File "setup.py", line 19, in LIB_PATH = libpath'find_lib_path' File "xgboost/libpath.py", line 46, in find_lib_path 'List of candidates:\n' + ('\n'.join(dll_path))) builtin.XGBoostLibraryNotFound: Cannot find XGBoost Library in the candidate path, did you install compilers and run build.sh in root path?

Could anyone explain to me how to fix it? thanks in advance.

谁能向我解释如何修复它?提前致谢。

回答by Gustavo

You get that message when trying to install the xgboost Python package without the xgboost binaries present. The proper way to install the xgboost Python package from source is the following (assuming you have a compiler such as gccinstalled):

当您尝试安装没有 xgboost 二进制文件的 xgboost Python 包时,您会收到该消息。从源代码安装 xgboost Python 包的正确方法如下(假设您安装了gcc等编译器):

git clone --recursive https://github.com/dmlc/xgboost.git
cd xgboost
./build.sh
cd python-package
python setup.py install

I prefer to do it inside a virtual environment. Note that the option --recursivewhen cloning the repo is essential since it will also clone folders from different repos such as dmlc-corewhich are necessary for building xgboost.

我更喜欢在虚拟环境中进行。请注意,克隆 repo 时的选项--recursive是必不可少的,因为它还会从不同的 repos 克隆文件夹,例如构建 xgboost 所必需的dmlc-core

回答by user2723494

The first answer's suggestions did not work for me, and left me with the same error as the original question.

第一个答案的建议对我不起作用,并给我留下了与原始问题相同的错误。

If I'm assuming correctly that your full error message is something like this:

如果我正确假设您的完整错误消息是这样的:

C:\Users\Matt\xgboost\python-package>python setup.py install
Traceback (most recent call last):
  File "setup.py", line 19, in <module>
    LIB_PATH = [os.path.relpath(libfile, CURRENT_DIR) for libfile in libpath['find_lib_path']()]
  File "xgboost/libpath.py", line 49, 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\Matt\xgboost\python-package\xgboost\xgboost.dll
C:\Users\Matt\xgboost\python-package\xgboost\../../lib/xgboost.dll
C:\Users\Matt\xgboost\python-package\xgboost\./lib/xgboost.dll
C:\Users\Matt\AppData\Local\Programs\Python\Python35\xgboost\xgboost.dll
C:\Users\Matt\xgboost\python-package\xgboost\../../windows/x64/Release/xgboost.dll
C:\Users\Matt\xgboost\python-package\xgboost\./windows/x64/Release/xgboost.dll

then the solution is to

那么解决方案是

1) Get/find/download the library that setup.py is looking for. Search the xgboost folder for .dllfiles. See if you can find something like xgboost.dllit might be called libxgboost.dll. If you can, move to step 2. If you cannot find it download it here

1) 获取/查找/下载 setup.py 正在寻找的库。在 xgboost 文件夹中搜索.dll文件。看看你能不能找到类似xgboost.dll它可能被称为 的东西libxgboost.dll。如果可以,请转到第 2 步。如果找不到,请在此处下载

2) Copy the .dll file into the xgboost/python-package/xgboost folder. If that .dll is not called xgboost.dll (i.e. if it's called libxgboost.dll) then change the name to xgboost.dll

2) 将 .dll 文件复制到 xgboost/python-package/xgboost 文件夹中。如果该 .dll 未称为 xgboost.dll(即,如果它称为 libxgboost.dll),则将名称更改为 xgboost.dll

3) Run the commands as outlined in Gustavo answer. Note these are meant to be run from Git Bash.

3) 运行 Gustavo 回答中概述的命令。请注意,这些旨在从 Git Bash 运行。

If you want a more soup-to-nuts tutorial, this was the best one I found.

如果你想要一个更全面的教程,这是我找到的最好的教程

回答by Patrick Stetz

The other answers didn't work for me so I installed xgboost through Conda commands as listed here.

其他答案对我不起作用,所以我通过此处列出的Conda 命令安装了 xgboost 。

Just run conda install -c conda-forge xgboost

赶紧跑 conda install -c conda-forge xgboost

回答by Ehsan Mehralian

thanks to Joe Nylandthat found the a good answer for this problem in here.
As he said (and also worked for me) you need to run following commands:

感谢Joe Nyland这里找到了这个问题的一个很好的答案。
正如他所说(也为我工作),您需要运行以下命令:

 $ brew install gcc@5
 $ pip install xgboost

回答by Syed Taha

Try this it worked for me:

试试这个它对我有用:

brew install gcc-5
brew install cmake
pip install xgboost

回答by mirekphd

In my case (Ubuntu 16.04, with CUDA 9.0) the Python library build was evidently broken by adding R library package to the cmake options list:

在我的情况下(Ubuntu 16.04,带有 CUDA 9.0),通过将 R 库包添加到 cmake 选项列表中,Python 库构建显然被破坏了:

1) python lib installation works OK:

1)python lib安装工作正常:

cmake .. -DUSE_CUDA=ON -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-${CUDA_VER} 
cd /tmp/xgboost/python-package && python3 setup.py install

2) adding '-DR_LIB=ON' switch to cmake breaks subsequent python library installation attempt:

2) 在 cmake 中添加 '-DR_LIB=ON' 开关会中断后续的 python 库安装尝试:

cmake .. -DUSE_CUDA=ON -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-${CUDA_VER} -DR_LIB=ON 
cd /tmp/xgboost/python-package && python3 setup.py install

> "XGBoostLibraryNotFound: Cannot find XGBoost Library in the candidate path, did you install compilers and run build.sh in root
> path?"

回答by Shradha

I faced the same error while installing xgboost using anaconda prompt because the installation of xgboost was interfering with the versions of some other pre-installed libraries. Installing xgboost by creating a virtual environment solved the issue.

我在使用 anaconda prompt 安装 xgboost 时遇到了同样的错误,因为 xgboost 的安装干扰了其他一些预安装库的版本。通过创建虚拟环境安装 xgboost 解决了这个问题。

On macOS and Linux:

在 macOS 和 Linux 上:

python3 -m pip install --user virtualenv #Install virtualenv module
python3 -m venv env #Create a virtual environment 'env'
source env/bin/activate #Activate virtual environment
pip install xgboost #Install xgboost

On Windows:

在 Windows 上:

py -m pip install --user virtualenv #Install virtualenv module
py -m venv env #Create a virtual environment 'env'
.\env\Scripts\activate #Activate virtual environment
pip install xgboost #Install xgboost

Refer https://packaging.python.org/guides/installing-using-pip-and-virtual-environmentsfor help regarding virtual environment.

有关虚拟环境的帮助,请参阅https://packaging.python.org/guides/installing-using-pip-and-virtual-environments

回答by Naganandini S

I had the same issues. I downloaded the file (xgboost.dll) from (https://picnet.com.au/blog/xgboost-windows-x64-binaries-for-download/) into the already existing xgboost folder (C:\Users\Naganandini\AppData\Roaming\Python\Python37\site-packages\xgboost). It's perfectly working now :)

我有同样的问题。我从 ( https://picnet.com.au/blog/xgboost-windows-x64-binaries-for-download/)下载文件 (xgboost.dll)到已经存在的 xgboost 文件夹 (C:\Users\Naganandini\ AppData\Roaming\Python\Python37\site-packages\xgboost)。它现在完美地工作:)