DLL Conflict/Crash with PyQt6 and onnxruntime
John Ehresman
jpe at wingware.com
Sun Nov 23 16:21:55 GMT 2025
It sounds like a version specific bug and a quick google search finds https://github.com/microsoft/onnxruntime/issues/26599
John
> On Nov 23, 2025, at 11:13 AM, Thomas Caswell <tcaswell at gmail.com> wrote:
>
> 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
More information about the PyQt
mailing list