DLL Conflict/Crash with PyQt6 and onnxruntime

Thomas Caswell tcaswell at gmail.com
Sun Nov 23 16:13:06 GMT 2025


This is the same underlying issue as
https://github.com/matplotlib/matplotlib/issues/28551 .

Summarizing that issue to bring to the attention of pypa has been on my
todo backlog for a while.  This may be a cleaner case to bring to pypa with
a more contemporaneous reproducer.

Tom

On Sun, Nov 23, 2025 at 7:12 AM Phil Thompson <phil at riverbankcomputing.com>
wrote:

> 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
>


-- 
Thomas Caswell
tcaswell at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20251123/c7737391/attachment.htm>


More information about the PyQt mailing list