I installed XGBoost using "conda install -c anaconda py-xgboost", it is missing OpenMP runtime, but I installed that too! What's going on?

Hello everyone,

I installed XGBoost using conda install -c anaconda py-xgboost, it throws the following error when importing the package in Python.

import xgboost
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/mike/opt/miniconda3/lib/python3.8/site-packages/xgboost/__init__.py", line 9, in <module>
    from .core import DMatrix, DeviceQuantileDMatrix, Booster
  File "/Users/mike/opt/miniconda3/lib/python3.8/site-packages/xgboost/core.py", line 174, in <module>
    _LIB = _load_lib()
  File "/Users/mike/opt/miniconda3/lib/python3.8/site-packages/xgboost/core.py", line 157, in _load_lib
    raise XGBoostError(
xgboost.core.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/mike/opt/miniconda3/lib/python3.8/site-packages/xgboost/lib/libxgboost.dylib, 6): Library not loaded: /usr/local/opt/libomp/lib/libomp.dylib\n  Referenced from: /Users/mike/opt/miniconda3/lib/python3.8/site-packages/xgboost/lib/libxgboost.dylib\n  Reason: image not found']

After reading the above error, I installed libomp using brew install libomp, and restarted the computer. Same error message after importing.

What is going on?

Thanks a lot!

You probably installed an outdated version of XGBoost. Please obtain the latest version, by running

pip install xgboost==1.3.3

What if you don’t have and can’t install pip on the computer?

I have Python 3.8.2. Is anaconda’s py-xgboost out-of-date? Is it only for Python? If so, it’s great, as can’t run other languages on this computer.

https://anaconda.org/anaconda/py-xgboost says it’s 0.90 version, which is quite outdated.

If using pip is not possible, you can also run conda install -c conda-forge py-xgboost instead. This will install https://anaconda.org/conda-forge/py-xgboost, which is the latest version.

Will conda install -c conda-forge py-xgboost install the same thing as pip install xgboost==1.3.3? Will they be in the SAME FOLDER?

I’m new to Python and sklearn, but isn’t anaconda one of the most popular distribution? How can they not update their packages?

Yes, it is the same 1.3.3 version.

Many packages are now maintained by conda-forge (community initiative) instead of Anaconda Inc. See https://conda-forge.org/docs/user/introduction.html for more details.

Just installed, it took less than 10 seconds. What a seamless process!

Thank you so much, you saved me so much time!

I know this may be different from the intended post, but do you recommend any tutorial for for xgboost learners? Thanks!

1 Like