Description
PyInstaller-bundled DearPyGui applications crash with an access violation (segfault) on add_theme() / setup_dearpygui() when the bundled VC runtime DLLs are older than the ones _dearpygui.pyd was compiled against.
create_context() works fine — the crash occurs on the first call that touches the rendering backend.
Root cause
_dearpygui.pyd in DearPyGui 2.2 is compiled with MSVC v14.44 and links against MSVCP140.dll, VCRUNTIME140.dll, and VCRUNTIME140_1.dll.
PyInstaller resolves DLL dependencies by walking the Windows DLL search path. If an older copy of these DLLs exists on PATH (common — JDK, Dell tools, and other software ship their own copies), PyInstaller bundles the old version instead of the one from System32.
In our case, PyInstaller picked up MSVCP140.dll v14.16 (VS 2017 era) from another application's directory on PATH. The ABI mismatch with the v14.44-compiled _dearpygui.pyd causes an access violation at runtime.
Minimal reproducer
# test.py
import dearpygui.dearpygui as dpg
dpg.create_context() # OK
with dpg.theme() as t: # ACCESS VIOLATION
pass
pyinstaller --collect-all dearpygui --console test.py
dist/test/test.exe # crashes
Verify by checking DLL versions in the bundle:
(Get-Item dist\test\_internal\MSVCP140.dll).VersionInfo.FileVersion
# If this shows 14.16.x instead of 14.4x.x, that's the problem
Workaround
In the .spec file, replace auto-detected VC runtimes with the correct ones from System32:
import os
_vc_dlls = {
'MSVCP140.DLL', 'MSVCP140_1.DLL', 'MSVCP140_2.DLL',
'VCRUNTIME140.DLL', 'VCRUNTIME140_1.DLL',
}
a.binaries = [
b for b in a.binaries
if b[0].upper() not in _vc_dlls
] + [
(dll, os.path.join(os.environ['SYSTEMROOT'], 'System32', dll), 'BINARY')
for dll in _vc_dlls
if os.path.exists(os.path.join(os.environ['SYSTEMROOT'], 'System32', dll))
]
Suggested fix
Ship the correct VC runtime DLLs inside the dearpygui package (next to _dearpygui.pyd), similar to how vcruntime140_1.dll is already shipped. This way PyInstaller's collect_all('dearpygui') bundles matching versions regardless of what's on the system PATH.
Alternatively, a PyInstaller hook (hook-dearpygui.py) could be provided to handle this automatically.
Environment
- DearPyGui 2.2 (also reproduced with 2.1.1)
- PyInstaller 6.19.0
- Python 3.14.3 and 3.13.2 (both affected)
- Windows 11 Pro (10.0.26200)
_dearpygui.pyd compiled with MSC v.1944 (MSVC 14.44)
Description
PyInstaller-bundled DearPyGui applications crash with an access violation (segfault) on
add_theme()/setup_dearpygui()when the bundled VC runtime DLLs are older than the ones_dearpygui.pydwas compiled against.create_context()works fine — the crash occurs on the first call that touches the rendering backend.Root cause
_dearpygui.pydin DearPyGui 2.2 is compiled with MSVC v14.44 and links againstMSVCP140.dll,VCRUNTIME140.dll, andVCRUNTIME140_1.dll.PyInstaller resolves DLL dependencies by walking the Windows DLL search path. If an older copy of these DLLs exists on
PATH(common — JDK, Dell tools, and other software ship their own copies), PyInstaller bundles the old version instead of the one fromSystem32.In our case, PyInstaller picked up
MSVCP140.dllv14.16 (VS 2017 era) from another application's directory on PATH. The ABI mismatch with the v14.44-compiled_dearpygui.pydcauses an access violation at runtime.Minimal reproducer
Verify by checking DLL versions in the bundle:
Workaround
In the
.specfile, replace auto-detected VC runtimes with the correct ones from System32:Suggested fix
Ship the correct VC runtime DLLs inside the
dearpyguipackage (next to_dearpygui.pyd), similar to howvcruntime140_1.dllis already shipped. This way PyInstaller'scollect_all('dearpygui')bundles matching versions regardless of what's on the system PATH.Alternatively, a PyInstaller hook (
hook-dearpygui.py) could be provided to handle this automatically.Environment
_dearpygui.pydcompiled with MSC v.1944 (MSVC 14.44)