Skip to content
Latchkey

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 0xf

Common 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

  1. Check which NumPy version the failing package was built against.
  2. Pin NumPy to a range the package supports, or upgrade the package to a build matching your NumPy.
  3. 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 pandas

How 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →