背景
pip install lightgbm -i https://pypi.tuna.tsinghua.edu.cn/simple
jupyter lab的notebook中执行
import lightgbm as lgb
lgb_classifier = lgb.LGBMClassifier()
出现下面错误
Referenced from: /opt/homebrew/anaconda3/envs/biligame/lib/python3.7/site-packages/lightgbm/lib_lightgbm.so
Reason: tried: '/usr/local/opt/libomp/lib/libomp.dylib' (no such file), '/usr/local/lib/libomp.dylib' (no such file), '/usr/lib/libomp.dylib' (no such file)
在网络上搜索了下,大概有2种方案
brew install open-mpi
Or
brew reinstall libomp
下载之前安装的lightgbm
pip uninstall lightgbm
重新用conda命令安装
conda install lightgbm
(coder) cynthia@192 ~ % conda install lightgbm
Collecting package metadata (current_repodata.json): done
Solving environment: -
Warning: 8 possible package resolutions (only showing differing packages):
- conda-forge/osx-64::ca-certificates-2022.5.18.1-h033912b_0, conda-forge/osx-64::certifi-2022.5.18.1-py38h50d1736_0, conda-forge/osx-64::openssl-3.0.3-hfe4f2af_0
...
打开Jupyter lab重新执行,可以导入正常