python import_error ai_generated partial

ImportError: DLL load failed while importing X

ID: python/importerror-dll-load-failed

Also available as: JSON · Markdown
80%Fix Rate
85%Confidence
50Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
311 active

Root Cause

Shared library (.so/.dll) not found. Missing system dependency or wrong architecture.

generic

Workarounds

  1. 90% success Install the missing system library: apt install libXXX-dev
    # Check what's missing:
    ldd /path/to/module.so | grep 'not found'

    Sources: https://docs.python.org/3/using/unix.html

  2. 85% success For conda environments, install with conda which bundles system libs
    conda install numpy  # includes MKL/OpenBLAS

    Sources: https://docs.conda.io/projects/conda/en/latest/

  3. 82% success On Windows, install Visual C++ Redistributable
    # Download from https://aka.ms/vs/17/release/vc_redist.x64.exe
    # Or install via winget:
    winget install Microsoft.VCRedist.2015+.x64

    Sources: https://docs.python.org/3/using/windows.html

Dead Ends

Common approaches that don't work:

  1. Reinstall Python 75% fail

    Usually not a Python issue — it's a missing system library

  2. Copy DLL from another machine 80% fail

    DLLs are architecture-specific and may have dependencies

Error Chain

Frequently confused with: