Skip to content
Latchkey

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.

python
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

  1. Confirm the runner Python architecture with python -c "import platform;print(platform.architecture())".
  2. Reinstall the package so pip selects the correct Windows wheel.
  3. Re-run the import to confirm the DLL resolves.
PowerShell
python -m pip install --upgrade --force-reinstall numpy

Install the required runtime

Install the Visual C++ redistributable the extension needs, or ensure the vendor DLL directory is on PATH.

PowerShell
choco install vcredist140 -y

How 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.

Related guides

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