XGBoostError: XGBoost Library (libxgboost.dylib) could not be loaded.

最初下载xgboost 用的是 pip install xgboost 但是不知道为什么,无法 import xgboost ,报错了XGBoostError: XGBoost Library (libxgboost.dylib) could not be loaded.

然后上网搜了下

给出的是 conda remove xgboost ,但是出现了

XGBoostError: XGBoost Library (libxgboost.dylib) could not be loaded.

我反应过来,我是用pip下的,这里的指令使用conda删的,所以只需要换成,pip uninstall xgboost 就可以了

之后只需要输入conda install py-xgboost

XGBoostError: XGBoost Library (libxgboost.dylib) could not be loaded.

 XGBoostError: XGBoost Library (libxgboost.dylib) could not be loaded.

发生了很多很多事情后,再 import xgboost 就成了

这里回顾一下上面的likely cause,我觉得这个xgboost 是一个写好的参考包,可能那样直接下下来和当前运行环境不匹配,而 conda install py-xgboost能在这里正常使用