ImportError: DLL load failed: cannot import NumPy binary components
ImportError: DLL load failed
$ python -c "import numpy"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File ".../site-packages/numpy/__init__.py", line ..., in <module>
from .core import *
File ".../site-packages/numpy/core/__init__.py", line ..., in <module>
raise ImportError("numpy.core.multiarray failed to import")
ImportError: numpy.core.multiarray failed to import
ImportError: DLL load failed: cannot find or load the specified module.
Why this happens
Causes include ABI mismatches between NumPy and the Python interpreter, missing system libraries (e.g., MKL, OpenBLAS), corrupted install, or using wheels built for different platforms.
Fix
Reinstall NumPy (prefer binary wheels via pip), ensure Python and compiled dependencies match (same ABI), or use conda which manages binary dependencies. On Linux, check linker errors and install required system libs.
Wrong code / action
pip install --no-binary=:all: numpy
# building from source with mismatched toolchain can cause failures
Fixed action
# Prefer a prebuilt wheel
pip install --upgrade --force-reinstall numpy
# or use conda
conda install numpy
In Python, verify
import numpy
print(numpy.__version__)
print(numpy.__file__)