DLL Conflict/Crash with PyQt6 and onnxruntime

Marius Wanko marius.wanko at gmail.com
Sun Nov 23 00:52:12 GMT 2025


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20251123/2410959d/attachment.htm>


More information about the PyQt mailing list