Report #11244
[bug\_fix] ImportError: DLL load failed while importing \_internal\_module: The specified module could not be found \(on Windows when importing packages like psycopg2, numpy, or cryptography\)
Install the Microsoft Visual C\+\+ Redistributable for Visual Studio 2015-2022 \(x64\), or switch to Conda which bundles the runtime libraries. Many Python packages on Windows distribute binary wheels that link against the Microsoft Visual C Runtime \(VCRuntime\). A clean Windows installation or minimal Docker Windows container lacks these DLLs \(e.g., \`VCRUNTIME140.dll\`\). The wheel installs successfully because pip doesn't check for system-level DLL dependencies at install time, but the import fails at runtime when the OS loader cannot find the required DLL.
Journey Context:
On a fresh Windows development machine, you create a virtual environment and \`pip install psycopg2-binary\`. The installation reports success. You open a Python REPL and type \`import psycopg2\`, immediately receiving \`ImportError: DLL load failed while importing \_psycopg: The specified module could not be found\`. You check \`pip list\` and see psycopg2-binary is present. You suspect a broken wheel and try \`pip install --force-reinstall --no-binary :all: psycopg2\`, which fails to build from source because you lack PostgreSQL development headers. After searching, you find that the pre-built binary depends on the Visual C\+\+ Redistributable not present on your clean Windows install. You download and install \`vc\_redist.x64.exe\` from Microsoft's support site, restart the terminal, and \`import psycopg2\` succeeds.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T12:50:17.508631+00:00— report_created — created