Everything was running fine in Jupyter notebook until I imported Xgboost. As soon as I import it I get the problem below. I have Python 3.8 and have installed it via terminal pip3 method, what should I do next?
---------------------------------------------------------------------------
XGBoostError Traceback (most recent call last)
<ipython-input-17-a81e4513ce38> in <module>
1 # Let's Learn about the stock market using XGBOOST
2
----> 3 import xgboost as xgb
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/xgboost/__init__.py in <module>
9 import warnings
10
---> 11 from .core import DMatrix, DeviceQuantileDMatrix, Booster
12 from .training import train, cv
13 from . import rabit # noqa
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/xgboost/core.py in <module>
173
174 # load the XGBoost library globally
--> 175 _LIB = _load_lib()
176
177
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/xgboost/core.py in _load_lib()
156 if not lib_success:
157 libname = os.path.basename(lib_paths[0])
--> 158 raise XGBoostError(
159 'XGBoost Library ({}) could not be loaded.\n'.format(libname) +
160 '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(/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/xgboost/lib/libxgboost.dylib, 6): Library not loaded: /usr/local/opt/libomp/lib/libomp.dylib\n Referenced from: /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/xgboost/lib/libxgboost.dylib\n Reason: image not found']
The Python "ModuleNotFoundError: No module named 'xgboost'" occurs when we forget to install the xgboost module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install xgboost command.
Installing xgboost in AnacondaStep 1: Install the current version of Python3 in Anaconda. Step 2: Check pip3 and python3 are correctly installed in the system. Step 3: To install xgboost library we will run the following commands in conda environment. How to Install Unity Hub on MacOS?
I solved it by installing libomp.dylib for Mac OSX. The answer was there all along.
You can do it by running the following command :
brew install libomp
for Mac OSX, just run 'brew install libomp'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With