import xgboost时出现如下错误 

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(/Users/opt/miniconda3/lib/python3.8/site-packages/xgboost/lib/libxgboost.dylib, 6): Library not loaded: /usr/local/opt/libomp/lib/libomp.dylib\n  Referenced from: /Users/opt/miniconda3/lib/python3.8/site-packages/xgboost/lib/libxgboost.dylib\n  Reason: image not found']

根据提示安装 libomp后,无效

再次尝试使用conda 安装py-xgboost == 》解决上述问题,安装成功后 再次导入xgboost是出现新问题,如下

ImportError: cannot import name 'CUDF_concat' from 'xgboost.compat' (/Users/opt/miniconda3/lib/python3.8/site-packages/xgboost/compat.py)

使用 brew install xgboost 尝试解决,出现如下错误

==> Installing dependencies for xgboost: scipy
==> Installing xgboost dependency: scipy
==> Pouring scipy-1.7.0.arm64_big_sur.bottle.tar.gz
tar: Error opening archive: Failed to open '/Users/Library/Caches/Homebrew/downloads/53c8571262d51367a124d616afb840f22508ed5c55ea82a4c75056ce819f390e--scipy-1.7.0.arm64_big_sur.bottle.tar.gz'
Error: Failure while executing; `tar --extract --no-same-owner --file /Users/Library/Caches/Homebrew/downloads/53c8571262d51367a124d616afb840f22508ed5c55ea82a4c75056ce819f390e--scipy-1.7.0.arm64_big_sur.bottle.tar.gz --directory /private/tmp/d20210813-12057-75d0ez` exited with 1. Here's the output:
tar: Error opening archive: Failed to open '/Users/Library/Caches/Homebrew/downloads/53c8571262d51367a124d616afb840f22508ed5c55ea82a4c75056ce819f390e--scipy-1.7.0.arm64_big_sur.bottle.tar.gz'

解决办法:根据提示缺什么依赖就手动安装什么依赖 ,如上图的提示,解决办法如下

brew install scipy

折腾一番后最终解决

 

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐