A Python package can install successfully on Windows and still fail when it loads compiled code. When a missing Microsoft C++ runtime DLL prevents TensorFlow from importing, installing the x64 Visual C++ Redistributable can restore the import in the same Python environment.
An import error that names msvcp140.dll or msvcp140_1.dll points to the C++ runtime. The more general DLL load failed while importing _pywrap_tensorflow_internal message appears in TensorFlow issue 88780 and can accompany other native dependency failures.
The Redistributable needs to match the architecture of the Python interpreter that loads TensorFlow. The x64 repair assumes TensorFlow is already installed in an environment with a compatible x64 CPython release.
Steps to fix TensorFlow DLL load failed errors on Windows:
- Check the Python version and architecture in PowerShell with the failing environment active.
python -c "import sys, sysconfig; print(sys.version.split()[0], sysconfig.get_platform())"
win-amd64 identifies x64 Python. TensorFlow 2.21.0 has Windows x64 wheels for CPython 3.10 through 3.13. If the interpreter or wheel is incompatible, the related installation guides cover choosing a supported environment.
Related: How to install TensorFlow with pip
Related: How to fix the no matching distribution error when installing TensorFlow with pip - Reproduce the TensorFlow import failure in that environment.
python -c "import tensorflow as tf; print(tf.__version__); print(tf.reduce_sum(tf.constant([1, 2, 3])))"
##### snipped ##### ImportError: Could not find the DLL(s) 'msvcp140.dll or msvcp140_1.dll'. ##### snipped #####
A traceback that names either C++ runtime DLL is enough to proceed directly to the Redistributable download.
- Check the C++ runtime DLLs if the traceback only reports a generic DLL load failure.
python -c "from ctypes import WinDLL; WinDLL('msvcp140.dll'); WinDLL('msvcp140_1.dll')"
OSError or FileNotFoundError naming either DLL means Python could not load it. If both DLLs load, the TensorFlow install error reference covers other causes of the import failure.
- Download the x64 Visual C++ Redistributable to your temporary folder if either runtime DLL failed to load.
curl.exe --fail --location --output "$env:TEMP\vc_redist.x64.exe" https://aka.ms/vc14/vc_redist.x64.exe
The download follows the link from Microsoft's Redistributable downloads page. A curl error means the download failed.
- Install the downloaded Visual C++ Redistributable only if the download succeeded and you have reviewed and agree to the Microsoft software license terms.
The installer requires administrator privileges and changes shared Windows runtime libraries. Quiet installation accepts the terms without displaying them.
Start-Process -FilePath "$env:TEMP\vc_redist.x64.exe" -ArgumentList '/install', '/quiet', '/norestart' -Verb RunAs -Wait
PowerShell waits for the installer to finish. /norestart prevents an automatic restart.
- Select Yes if User Account Control opens and lists Microsoft Corporation as the verified publisher.
If the verified publisher is missing or differs, select No.
- Retest the TensorFlow import in the same Python environment.
python -c "import tensorflow as tf; print(tf.__version__); print(tf.reduce_sum(tf.constant([1, 2, 3])))"
2.21.0 ##### snipped ##### tf.Tensor(6, shape=(), dtype=int32)
The version line confirms that the import completed. The tensor value 6 confirms that TensorFlow can also run the sum. TensorFlow may also print CPU information around these lines.