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
1 Like

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.

1 Like

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

I have XGBoost version 1.4.2, Python 3.9. While
import xgboost
print(xgboost.version)
However, the message is:
‘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.’
    While running ‘brew install libomp’, ‘brew’ was not recognized. And ‘pip’ didn’t find libomp.
    Please, help.

@Yuri Have you tried running conda install -c conda-forge py-xgboost?

Yeah, I tried. The process continued around 30 min, after that I stopped it. I thought something was wrong. Should I repeat it? Thanks.

Hello, I am having a similar problem.

Hardware specs:
macOS Big Sur. (version 11.5.1)
MacBook Pro (16-inch, 2019)
Processor: 2.6 GHz 6-Core Intel Core i7

xgboost version 1.5.1

Looks like I have Open MP installed:

❯ brew install libomp
Warning: libomp 13.0.0 is already installed and up-to-date.
To reinstall 13.0.0, run:
  brew reinstall libomp

I have tried installing through various package managers (e.g., pip and conda-forge).

I am able to run xgboost without this error if I install version 0.9, but it seems likely anything in the 1.x range comes up with this error.

If I run xgboost in a linux-based docker container, I don’t have any problem. If anyone had thoughts on how to make this work with Mac, it ould be greatly appreciated.

Thanks!
Tom