How to Install XGBoost and LightGBM in CI Without libgomp Errors
XGBoost and LightGBM install from wheels easily, but both link against OpenMP - so on a slim image import fails with "libgomp.so.1 cannot open shared object file".
Both libraries ship manylinux wheels with their C++ cores bundled, so pip succeeds. The classic runtime failure is the missing OpenMP runtime: the wheels dlopen libgomp.so.1, which slim images do not include. LightGBM also needs libgomp on Linux for multithreading.
Why it fails in CI
The prebuilt wheels install fine, but at runtime they link to the OpenMP runtime libgomp.so.1. Minimal images (python:3.x-slim, some bases) omit it, so import xgboost or import lightgbm aborts even though the install succeeded.
OSError: libgomp.so.1: cannot open shared object fileon import.- On macOS-based images, a missing
libomp(OpenMP) for LightGBM. No matching distributionon a brand-new Python or musl with no wheel.
Install it reliably
Keep the wheels and add the OpenMP runtime. On Debian/Ubuntu that is libgomp1; on Alpine it is libgomp. Pin a supported Python and stay on glibc.
# Add the OpenMP runtime the wheels link against
apt-get update && apt-get install -y libgomp1 # Debian/Ubuntu
# apk add --no-cache libgomp # Alpine
pip install --only-binary=:all: xgboost lightgbmCache & speed
Cache ~/.cache/pip so the wheels are reused, and bake libgomp1 into the image so apt does not run every job.
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: pip-boosting-${{ hashFiles('requirements*.txt') }}Common errors
| Error | Cause | Fix |
|---|---|---|
| libgomp.so.1: cannot open shared object file | No OpenMP runtime | apt-get install libgomp1 |
| LightGBM OpenMP error on macOS image | Missing libomp | Install libomp/libgomp |
| No matching distribution (new Python) | No wheel yet | Pin a supported Python |
| Failed building wheel | Source build (CMake) | Force --only-binary |
Key takeaways
- XGBoost/LightGBM wheels need the OpenMP runtime - install libgomp1.
- Keep the wheels; never compile their C++ cores in CI.
- Bake libgomp1 into the image and cache ~/.cache/pip.