【问题标题】:I am not able to run lightgbm on Mac because of an OSerror: libomp.dylib' (no such file)I am not able to run lightgbm on Mac because of an OSerror: libomp.dylib\' (no such file)
【发布时间】:2022-12-19 03:17:23
【问题描述】:

I am not able to run lightbm on my MAC. I already tried all the solutions that I found but I can't get rid of the problem.

When I import lightgbm the following OSERROR appears:

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
Input In [2], in <cell line: 6>()
  4 from sklearn.metrics import accuracy_score
  5 import time
----> 6 from lightgbm import LGBMClassifier
  7 from xgboost import XGBClassifier
  8 print('make classification ...')

File ~/opt/anaconda3/lib/python3.9/site-packages/lightgbm/__init__.py:8, in <module>
  2 """LightGBM, Light Gradient Boosting Machine.
  3 
  4 Contributors: https://github.com/microsoft/LightGBM/graphs/contributors.
  5 """
  6 from pathlib import Path
----> 8 from .basic import Booster, Dataset, Sequence, register_logger
  9 from .callback import early_stopping, log_evaluation, print_evaluation, record_evaluation, reset_parameter
 10 from .engine import CVBooster, cv, train

File ~/opt/anaconda3/lib/python3.9/site-packages/lightgbm/basic.py:110, in <module>
106         raise LightGBMError(lib.LGBM_GetLastError().decode('utf-8'))
107     return lib
--> 110 _LIB = _load_lib()
113 NUMERIC_TYPES = (int, float, bool)
116 def _safe_call(ret: int) -> None:

File ~/opt/anaconda3/lib/python3.9/site-packages/lightgbm/basic.py:101, in _load_lib()
 99 if len(lib_path) == 0:
100     return None
--> 101 lib = ctypes.cdll.LoadLibrary(lib_path[0])
102 lib.LGBM_GetLastError.restype = ctypes.c_char_p
103 callback = ctypes.CFUNCTYPE(None, ctypes.c_char_p)

File ~/opt/anaconda3/lib/python3.9/ctypes/__init__.py:460, in LibraryLoader.LoadLibrary(self, name)
459 def LoadLibrary(self, name):
--> 460     return self._dlltype(name)

File ~/opt/anaconda3/lib/python3.9/ctypes/__init__.py:382, in CDLL.__init__(self, name, mode, handle, use_errno, use_last_error, winmode)
379 self._FuncPtr = _FuncPtr
381 if handle is None:
--> 382     self._handle = _dlopen(self._name, mode)
383 else:
384     self._handle = handle

OSError: dlopen(/Users/pedropestana/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/pedropestana/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).   

I already tried to reinstall the necessary libraries to install lightgbm but it still remains.

【问题讨论】:

    标签: macos lightgbm


    【解决方案1】:

    ForLinuxusers,glibc>= 2.14 is required. Also, in some rare cases, when you hit OSError: libgomp.so.1: cannot open shared object file: No such file or directory error during importing LightGBM, you need to install OpenMP runtime library separately (use your package manager and search for lib[g|i]omp for doing this).

    FormacOS(we provide wheels for 3 newest macOS versions) users:

    Starting from version 2.2.1, the library file in distribution wheels is built by theApple Clang(Xcode_8.3.3 for versions 2.2.1 - 2.3.1, Xcode_9.4.1 for versions 2.3.2 - 3.3.2 and Xcode_10.3 from version 4.0.0) compiler. This means that you don't need to install the gcc compiler anymore. Instead of that you need to install theOpenMPlibrary, which is required for running LightGBM on the system with theApple Clangcompiler. You can install theOpenMPlibrary by the following command: brew install libomp.

    -- LightGBM Python-package docs

    tl;dr: for , brew install libomp

    【讨论】:

    • this is not working for me.
    【解决方案2】:
    conda install -c conda-forge lightgbm
    

    【讨论】:

      猜你喜欢
      • 2022-12-02
      • 2020-02-09
      • 2022-12-26
      • 2022-12-02
      • 2023-03-12
      • 1970-01-01
      • 2016-06-07
      • 2017-07-05
      • 2018-11-20
      相关资源
      最近更新 更多