Python "numpy.core.multiarray failed to import" (ABI) in CI
A package with a NumPy C extension (SciPy, OpenCV, pandas) was compiled against one NumPy ABI and is now loaded with an incompatible NumPy. The binary interface does not match, so the multiarray import fails.
What this error means
Importing a NumPy-dependent package fails with "ImportError: numpy.core.multiarray failed to import", often after NumPy 2.0 was installed alongside packages built for 1.x.
python
ImportError: numpy.core.multiarray failed to import
RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xfCommon causes
A package built for a different NumPy major version
A wheel compiled against NumPy 1.x is loaded with NumPy 2.x (or vice versa); the C ABI changed, so the import breaks.
NumPy upgraded independently of its dependents
An unpinned resolve pulled a newer NumPy than the binary dependents were built against.
How to fix it
Pin NumPy to a compatible major version
- Check which NumPy version the failing package was built against.
- Pin NumPy to a range the package supports, or upgrade the package to a build matching your NumPy.
- Recompile the lockfile so the pair stays consistent.
Terminal
pip install "numpy<2" "opencv-python==4.9.0.80"Reinstall the dependents against the installed NumPy
Force fresh binaries so the extensions match the NumPy in the environment.
Terminal
pip install --force-reinstall --no-cache-dir scipy pandasHow to prevent it
- Pin NumPy and its binary dependents together.
- Upgrade the whole scientific stack as a group, not piecemeal.
- Commit a lockfile so the ABI-coupled versions are fixed.
Related guides
Python "ValueError: numpy.dtype size changed" (binary incompatibility) in CIFix "ValueError: numpy.dtype size changed, may indicate binary incompatibility" in CI - a Cython/C extension…
Python "Segmentation fault (core dumped)" in a C extension in CIFix "Segmentation fault (core dumped)" from a Python C extension in CI - a native crash terminated the interp…
Python "ImportError: libffi.so.X: cannot open shared object file" in CIFix "ImportError: libffi.so.X: cannot open shared object file" in CI - a Python extension needs the system li…