DLL Conflict/Crash with PyQt6 and onnxruntime
Phil Thompson
phil at riverbankcomputing.com
Sun Nov 23 12:12:21 GMT 2025
On 23/11/2025 00:52, Marius Wanko wrote:
> Hi,
>
> I encountered an access violation (0xC0000005) when importing
> onnxruntime
> along PyQt6 on Windows 10/11. On the python end this raises
> "ImportError:
> DLL load failed while importing onnxruntime_pybind11_state: A dynamic
> link
> library (DLL) initialization routine failed."
>
> I tracked it down to the system DLLs vcruntime140*.dll and
> msvcp140*.dll,
> which are bundled in the PyQt6 PyPI wheels (Qt6/bin/) whereas
> onnxruntime
> seem to be compiled against the corresponding system dlls (I checked
> dependencies). If PyQt6 is imported first, the crash occurs when
> onnxruntime initializes. The Windows SDK debugger shows me
> "MSVCP140!mtx_do_lock" in the stack trace. When I delete the bundled
> dlls,
> the error disappears and onnxruntime works as expected.
>
> I just wanted to communicate this, I'm not going to argue whether the
> bundling is a good idea or not.
>
> Marius
I don't know if it is a good idea either. Does anybody know what current
best practice is?
Historically I don't think you could depend on those DLLs being already
installed. I would hope that that has changed.
Phil
More information about the PyQt
mailing list