我在移动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?
有人可以向我解释如何修复它吗? 提前谢谢。
答案 0 :(得分:16)
在尝试安装xgboost Python软件包而不存在xgboost二进制文件时,会收到该消息。从源代码安装xgboost Python软件包的正确方法如下(假设您安装了 gcc 等编译器):
git clone --recursive https://github.com/dmlc/xgboost.git
cd xgboost
./build.sh
cd python-package
python setup.py install
我更喜欢在虚拟环境中进行。请注意,克隆存储库时选项 - recursive 是必不可少的,因为它还会从构建xgboost所需的不同存储库(例如 dmlc-core )中克隆文件夹。
答案 1 :(得分:4)
第一个回答的建议对我不起作用,给我留下了与原始问题相同的错误。
如果我正确地假设您的完整错误消息是这样的:
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
然后解决方案是
1)获取/查找/下载setup.py正在寻找的库。在xgboost文件夹中搜索.dll
个文件。看看您是否可以找到类似xgboost.dll
的内容,可能会将其命名为libxgboost.dll
。如果可以,请转到步骤2.如果找不到download it here
2)将.dll文件复制到xgboost / python-package / xgboost文件夹中。如果.dll没有被称为xgboost.dll(即如果它被称为libxgboost.dll),那么将名称更改为xgboost.dll
3)运行Gustavo答案中概述的命令。注意这些是从Git Bash运行的。
如果你想要更多的汤到坚果教程,this was the best one I found.
答案 2 :(得分:3)
其他答案对我没有用,所以我通过Conda命令安装了xgboost listed here。
只需运行conda install -c conda-forge xgboost
答案 3 :(得分:2)
感谢Joe Nyland在here中找到了解决此问题的好方法。
正如他所说(并且也为我工作),你需要运行以下命令:
$ brew install gcc@5
$ pip install xgboost
答案 4 :(得分:2)
尝试一下对我有用:
brew install gcc-5
brew install cmake
pip install xgboost
答案 5 :(得分:0)
在我的情况下(Ubuntu 16.04,使用CUDA 9.0),通过向cmake选项列表中添加R库包,显然破坏了Python库的构建:
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)将'-DR_LIB = ON'开关添加到cmake会中断随后的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?"
答案 6 :(得分:0)
在使用anaconda提示安装xgboost时,我遇到了相同的错误,因为xgboost的安装会干扰已经安装的其他库的版本。通过创建虚拟环境安装xgboost解决了该问题。
在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
在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
有关虚拟环境的帮助,请参见https://packaging.python.org/guides/installing-using-pip-and-virtual-environments。
答案 7 :(得分:0)
我有同样的问题。我从以下位置下载文件(xgboost.dll) (https://picnet.com.au/blog/xgboost-windows-x64-binaries-for-download/) 到已经存在的xgboost文件夹中 (C:\ Users \ Naganandini \ AppData \ Roaming \ Python \ Python37 \ site-packages \ xgboost)。 现在一切正常:)
答案 8 :(得分:0)
在C:\ Users <您的用户名>目录下搜索xgboost.dll文件。 如果已安装xgboost,则应该在某处找到xgboost.dll文件的副本。
找到xgboost.dll文件后,只需将其复制到错误消息中提到的路径之一, 例如C:\ Users <您的用户名> \ AppData \ Roaming \ Python \ Python37 \ site-packages \ xgboost \。导入现在应该可以进行。
答案 9 :(得分:0)
1。我从anaconda提示符开始安装conda:
(base) C:\Users\abhi.b>conda install -c anaconda py-xgboost
这导致以下错误:
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: \
Found conflicts! Looking for incompatible packages.
This can take several minutes. Press CTRL-C to abort.|
failed
UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:
Specifications:
- py-xgboost -> python[version='>=2.7,<2.8.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0|>=3.5,<3.6.0a0']
Your python: python=3.8
If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.
决定不遵循这条路,因为探索python降级对我来说不是一个选择。
2。之后,我在下面的链接上遵循了“最终的工作原理”: https://medium.com/analytics-vidhya/this-is-what-you-should-do-if-you-fail-to-install-the-latest-or-an-older-version-of-xgboost-on-7942a7641eee
但是我遇到与其他用户相同的错误::
>>> import xgboost as xgb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\abhi.b\Anaconda3\lib\site-packages\xgboost\__init__.py", line 11, in <module>
from .core import DMatrix, Booster
File "C:\Users\abhi.b\Anaconda3\lib\site-packages\xgboost\core.py", line 161, in <module>
_LIB = _load_lib()
File "C:\Users\abhi.b\Anaconda3\lib\site-packages\xgboost\core.py", line 123, in _load_lib
lib_paths = find_lib_path()
File "C:\Users\abhi.b\Anaconda3\lib\site-packages\xgboost\libpath.py", line 45, in find_lib_path
raise XGBoostLibraryNotFound(
xgboost.libpath.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\abhi.b\Anaconda3\lib\site-packages\xgboost\xgboost.dll
C:\Users\abhi.b\Anaconda3\lib\site-packages\xgboost\../../lib/xgboost.dll
C:\Users\abhi.b\Anaconda3\lib\site-packages\xgboost\./lib/xgboost.dll
C:\Users\abhi.b\Anaconda3\xgboost\xgboost.dll
C:\Users\abhi.b\Anaconda3\lib\site-packages\xgboost\../../windows/x64/Release/xgboost.dll
C:\Users\abhi.b\Anaconda3\lib\site-packages\xgboost\./windows/x64/Release/xgboost.dll
>>> exit()
按上述链接下载xgboost.dll的链接- https://picnet.com.au/blog/xgboost-windows-x64-binaries-for-download/ 我不清楚,所以我决定不关注此话题。
3。最后,该解决方案对我来说非常简单,打开ANACONDA PROMPT和Type
(base) C:\Users\abhi.b>pip install xgboost
这导致
Collecting xgboost
Downloading xgboost-1.2.1-py3-none-win_amd64.whl (86.5 MB)
|████████████████████████████████| 86.5 MB 1.7 MB/s
Requirement already satisfied: scipy in c:\users\abhi.b\anaconda3\lib\site-packages (from xgboost) (1.5.0)
Requirement already satisfied: numpy in c:\users\abhi.b\anaconda3\lib\site-packages (from xgboost) (1.18.5)
Installing collected packages: xgboost
Successfully installed xgboost-1.2.1
然后转到python提示符
(base) C:\Users\abhi.b>python
>>>import xgboost as xgb
或者您可以在IDE上键入相同的命令,例如Spyder等 瞧!