XGBoost Library (libxgboost.so) could not be loaded.
Third-person routing text. Fixes xgboost failing on Linux with XGBoost Library (libxgboost.so) could not be loaded: the OpenMP runtime libgomp is missing. Install the libgomp system package. Use when an agent hits this importing xgboost on Linux. Not for macOS or Windows.
TL;DR: xgboost's native library needs the OpenMP runtime and your Linux box does not have it. Install the libgomp system package and the import works.
The error
XGBoost Library (libxgboost.so) could not be loaded.Fix it
Install the OpenMP runtime. On Debian/Ubuntu:
sudo apt install libgomp1On RHEL/Fedora:
sudo dnf install libgomp. Expected: package installs.Verify:
python -c "import xgboost; print(xgboost.__version__)"Expected: prints the version, no error.
- If the message lists other likely causes, read past the generic checklist; the missing-libgomp line is the real one on minimal Linux images.
When this applies
Use this when import xgboost on Linux raises the libxgboost.so load error.
When it does not apply
On macOS the missing library is libomp.dylib (brew install libomp). If you are on a 32-bit Python or a mismatched glibc, those are separate causes listed in the same message.
Compatibility
Linux, pip-installed xgboost wheels.
Root cause
xgboost's compiled core links against libgomp for OpenMP parallelism. Minimal containers and stripped servers often lack the libgomp runtime package, so the loader fails and xgboost reports the generic could-not-be-loaded message.
Edge cases
In docker, add libgomp1 to the image so redeploys do not regress. The conda-forge xgboost bundles its own OpenMP runtime and sidesteps this entirely.