macOs Catalinaでlightgbmを使用して遭遇したピットと解決方法

2534 ワード

pip install lightgbm

インストールは成功しましたが、次のようにエラーが発生しました.
OSError: dlopen(/Users/Cyan/anaconda3/lib/python3.7/site-packages/lightgbm/lib_lightgbm.so, 6): Library not loaded: /usr/local/opt/libomp/lib/libomp.dylib 
Referenced from: /Users/Cyan/anaconda3/lib/python3.7/site-packages/lightgbm/lib_lightgbm.so 
Reason: image not found

最終的には、公式ドキュメントで解決します.
brew install libomp

上記のコマンドでlibompを1つインストールすれば、lightgbmは正常に使用できます.
公式文書は次のとおりです.
For macOS users: Starting from version 2.2.1, the library file in distribution wheels is built by the Apple Clang (Xcode_8.3.3) compiler. This means that you don’t need to install the gcc compiler anymore. Instead of that you need to install the OpenMPlibrary, which is required for running LightGBM on the system with the Apple Clang compiler. You can install the OpenMP library by the following command: brew install libomp.