I am trying to run below code in mac.
## Hyperparameter optimization using RandomizedSearchCV
from sklearn.model_selection import RandomizedSearchCV, GridSearchCV
from xgboost import XGBClassifier
It is giving me below error. Please help me, I have been trying to solve this issue more than two days. But no luck.
The error popped up are shown below,
---------------------------------------------------------------------------
XGBoostError Traceback (most recent call last)
<ipython-input-141-84c898b0388e> in <module>
1 ## Hyperparameter optimization using RandomizedSearchCV
2 from sklearn.model_selection import RandomizedSearchCV, GridSearchCV
----> 3 from xgboost import XGBClassifier
~/opt/anaconda3/lib/python3.8/site-packages/xgboost/__init__.py in <module>
7 import os
8
----> 9 from .core import DMatrix, DeviceQuantileDMatrix, Booster
10 from .training import train, cv
11 from . import rabit # noqa
~/opt/anaconda3/lib/python3.8/site-packages/xgboost/core.py in <module>
171
172 # load the XGBoost library globally
--> 173 _LIB = _load_lib()
174
175
~/opt/anaconda3/lib/python3.8/site-packages/xgboost/core.py in _load_lib()
154 if not lib_success:
155 libname = os.path.basename(lib_paths[0])
--> 156 raise XGBoostError(
157 'XGBoost Library ({}) could not be loaded.\n'.format(libname) +
158 'Likely causes:\n' +
XGBoostError: XGBoost Library (libxgboost.dylib) could not be loaded.
Likely causes:
* OpenMP runtime is not installed (vcomp140.dll or libgomp-1.dll for Windows, libomp.dylib for Mac OSX, libgomp.so for Linux and other UNIX-like OSes). Mac OSX users: Run `brew install libomp` to install OpenMP runtime.
* You are running 32-bit Python on a 64-bit OS
Error message(s): ['dlopen(/Users/danishali/opt/anaconda3/lib/python3.8/site-packages/xgboost/lib/libxgboost.dylib, 6): Library not loaded: /usr/local/opt/libomp/lib/libomp.dylib\n Referenced from: /Users/danishali/opt/anaconda3/lib/python3.8/site-packages/xgboost/lib/libxgboost.dylib\n Reason: image not found']
I had the same issue but solved it by running the flowing command on terminal
brew install libomp