diff --git a/onnxruntime/python/_pybind_state.py.in b/onnxruntime/python/_pybind_state.py.in index 4fa859a559..c77b206d73 100644 --- a/onnxruntime/python/_pybind_state.py.in +++ b/onnxruntime/python/_pybind_state.py.in @@ -8,16 +8,22 @@ Ensure that dependencies are available and then load the extension module. import os import platform import sys +import warnings from . import _ld_preload # noqa: F401 if platform.system() == "Windows": from . import version_info + # If on Windows, check if this import error is caused by the user not installing the 2019 VC Runtime + # The VC Redist installer usually puts the VC Runtime dlls in the System32 folder, but it may also be found + # in some other locations or in some case Windows is not installed at C:\Windows. + # TODO, we may want to try to load the VC Runtime dlls instead of checking if the hardcoded file path + # is valid, and raise ImportError if the load fails if version_info.vs2019 and platform.architecture()[0] == "64bit": if not os.path.isfile("C:\\Windows\\System32\\vcruntime140_1.dll"): - raise ImportError( - "Microsoft Visual C++ Redistributable for Visual Studio 2019 not installed on the machine.") + warnings.warn("Please install the 2019 Visual C++ runtime and then try again") + @ONNXRUNTIME_SETDLOPENFLAGS_GLOBAL@ from .onnxruntime_pybind11_state import * # noqa @ONNXRUNTIME_SETDLOPENFLAGS_LOCAL@