Package seems not to be well installed (file not found)

Question:

I am using lazypredict to try to find good algorithms (source: here). The command pip install yields no error, and I have also done the upgrade of the package, yet when I use from lazypredict.Supervised import LazyRegressor (which should work according to the documentation) I end up with the following error:

OSError: dlopen(/Users/gaetanlefloch/opt/anaconda3/lib/python3.9/site-packages/lightgbm/lib_lightgbm.so, 0x0006): Library not loaded: /usr/local/opt/libomp/lib/libomp.dylib
Referenced from: /Users/gaetanlefloch/opt/anaconda3/lib/python3.9/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)

Did someone have the same issue (with lazypredict or another package), and how can I overcome it without eventually doing a manual installation ?

Asked By: GaëtanLF

||

Answers:

Based on the presence of a /Users/... path in the logs you shared, I’m assuming you are on macOS.

LightGBM requires OpenMP by default, and links to it dynamically. That means that it expects to find it installed on your system at runtime.

Use Homebrew (link) to install OpenMP.

brew install libomp

If you are using lightgbm < 4.0 and Homebrew gives you libomp>=15.0, you may need to help Python find that library.

You can do that modifying environment variable LD_LIBRARY_PATH.

export LD_LIBRARY_PATH=/usr/local/opt/libomp/lib:"${LD_LIBRARY_PATH}"

Or by using brew link.

brew link --force libomp
Answered By: James Lamb
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.