Python "ImportError: DLL load failed while importing" on Windows in CI
A compiled extension module loaded on Windows, but the dynamic loader could not resolve one of its dependent DLLs (a Visual C++ runtime, an MKL library, or the wrong-bitness binary). The import fails.
What this error means
On a windows-latest runner an import fails with "ImportError: DLL load failed while importing X: The specified module could not be found." Pure-Python code is unaffected; only the native extension breaks.
Traceback (most recent call last):
File "test_app.py", line 1, in <module>
import numpy
ImportError: DLL load failed while importing _multiarray_umath: The specified module could not be found.Common causes
A required runtime DLL is missing
The extension links against a Visual C++ redistributable or vendor DLL (e.g. MKL) that is not installed or not on PATH.
Architecture or Python-version mismatch
A 32-bit wheel on a 64-bit interpreter (or a wheel built for a different Python) loads but cannot resolve its native dependencies.
How to fix it
Reinstall matching wheels for the runner
- Confirm the runner Python architecture with
python -c "import platform;print(platform.architecture())". - Reinstall the package so pip selects the correct Windows wheel.
- Re-run the import to confirm the DLL resolves.
python -m pip install --upgrade --force-reinstall numpyInstall the required runtime
Install the Visual C++ redistributable the extension needs, or ensure the vendor DLL directory is on PATH.
choco install vcredist140 -yHow to prevent it
- Pin packages to versions that ship Windows wheels for your Python version.
- Match the interpreter architecture to the wheels you install.
- Install required VC++ runtimes as an explicit CI step on Windows.