jon*_*jon 17 python jupyter xgboost jupyter-notebook
在我导入 Xgboost 之前,一切在 Jupyter 笔记本中运行良好。一旦我导入它,我就会遇到下面的问题。我有 Python 3.8 并通过终端 pip3 方法安装了它,接下来我该怎么做?
---------------------------------------------------------------------------
XGBoostError Traceback (most recent call last)
<ipython-input-17-a81e4513ce38> in <module>
1 # Let's Learn about the stock market using XGBOOST
2
----> 3 import xgboost as xgb
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/xgboost/__init__.py in <module>
9 import warnings
10
---> 11 from .core import DMatrix, DeviceQuantileDMatrix, Booster
12 from .training import train, cv
13 from . import rabit # noqa
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/xgboost/core.py in <module>
173
174 # load the XGBoost library globally
--> 175 _LIB = _load_lib()
176
177
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/xgboost/core.py in _load_lib()
156 if not lib_success:
157 libname = os.path.basename(lib_paths[0])
--> 158 raise XGBoostError(
159 'XGBoost Library ({}) could not be loaded.\n'.format(libname) +
160 'Likely causes:\n' +
XGBoostError: XGBoost Library (libxgboost.dylib) could not be loaded.
Likely causes:
* OpenMP runtime is not installed (vcomp140.dll or libgomp-1.dll for Windows,
libomp.dylib for Mac OSX, libgomp.so for Linux and other UNIX-like OSes).
Mac OSX users: Run `brew install libomp` to install OpenMP runtime.
* You are running 32-bit Python on a 64-bit OS
Error message(s): ['dlopen(/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/xgboost/lib/libxgboost.dylib, 6): Library not loaded: /usr/local/opt/libomp/lib/libomp.dylib\n Referenced from: /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/xgboost/lib/libxgboost.dylib\n Reason: image not found']
Run Code Online (Sandbox Code Playgroud)
jon*_*jon 25
我通过为 Mac OSX 安装 libomp.dylib 解决了这个问题。答案一直都在。
您可以通过运行以下命令来完成:
brew install libomp
小智 12
如果你使用anaconda,你可以使用:
conda install py-xgboost
Run Code Online (Sandbox Code Playgroud)
小智 9
原因是 xgboost 正在以下位置寻找动态库,而这不是它可能安装的位置。
Reason: tried: '/libomp.dylib' (no such file), '/usr/local/opt/libomp/lib/libomp.dylib' (no such file), '/libomp.dylib' (no such file), '/Users/michaeltu/third-party/lib/libomp.dylib' (no such file)"]
Run Code Online (Sandbox Code Playgroud)
首先,brew install libomp如果您还没有这样做。
之后,检查brew安装库的位置。
$ brew info libomp
libomp: stable 12.0.0 (bottled)
LLVM's OpenMP runtime library
https://openmp.llvm.org/
/opt/brew/Cellar/libomp/12.0.0 (9 files, 1.5MB) *
Run Code Online (Sandbox Code Playgroud)
我们看到它安装在这里:
$ ls /opt/brew/Cellar/libomp/12.0.0/lib/
libomp.a libomp.dylib
Run Code Online (Sandbox Code Playgroud)
制作一个 simlink(基于您安装的 libomp 版本):
$ mkdir -p /usr/local/opt/libomp/
$ ln -s /opt/brew/Cellar/libomp/12.0.0/lib /usr/local/opt/libomp/lib
Run Code Online (Sandbox Code Playgroud)
尝试再次导入。这能够解决我的问题。
| 归档时间: |
|
| 查看次数: |
20088 次 |
| 最近记录: |