Installing LightGBM in MacOS Mojave — Issue sorted

Love IoT
2 min readMar 9, 2019

--

I tried to install the lightgbm library for Python to run the feature selection algorithms and got the following error.

Issue

OSError:dlopen(/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/lightgbm/lib_lightgbm.so, 6): Library not loaded: /usr/local/opt/libomp/lib/libomp.dylib   Referenced from: /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/lightgbm/lib_lightgbm.so   
Reason: image not found

Solution

Install the setup tools if you haven’t done this before by following the below

  1. Ensure pip, setuptools, and wheel are up to date
python -m pip install --upgrade pip setuptools wheel

Useful links

https://packaging.python.org/tutorials/installing-packages/

2. 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 OpenMP library, 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.
  • For version smaller than 2.2.1 and not smaller than 2.1.2, gcc-8 with OpenMP support must be installed first. Refer to Installation Guide for installation of gcc-8 with OpenMP support.
  • For version smaller than 2.1.2, gcc-7 with OpenMP is required.

Install wheel via pip install wheel first. After that download the wheel file and install from it:

pip install lightgbm

Build from Sources

pip install --no-binary :all: lightgbm

For Linux and macOS users, installation from sources requires installed CMake.

For macOS users, you can perform installation either with Apple Clang or gcc.

More on how to install LighGBM in MacOS latest versions could be found in

This document is extracted from the above link from github.com.

--

--