PyInstaller with PyQt5 Generates "DLL load failed" Error for QtPrintSupport

25 views Asked by At

I've developed a Python application using PyQt5 and successfully packaged it with PyInstaller. However, after compiling the application with Inno Setup Compiler and installing it on my PC, I encounter a runtime error when trying to launch the program. The error message is as follows:

Traceback (most recent call last):
  File "new_main.py", line 17, in <module>
ImportError: DLL load failed while importing QtPrintSupport: The specified module could not be found.

Steps Taken:

  • I've reinstalled the PyQT5 packages to ensure they're up to date.
  • Moved the .dll files to my distribution folder based on the suggestions I found online.
  • Double-checked to ensure all dependency DLLs are included in the distribution.

Despite these efforts, the issue persists. Here is the .spec file I'm using for PyInstaller:

# -*- mode: python ; coding: utf-8 -*-

block_cipher = None

a = Analysis(
    ['new_main.py'],
    pathex=[],
    binaries=[
        ('C:\\Users\\damon\\PycharmProjects\\device_db_sql\\venv\\Lib\\site-packages\\PyQt5\\Qt5\\bin\\Qt5Gui.dll', '.'),
        ('C:\\Users\\damon\\PycharmProjects\\device_db_sql\\venv\\Lib\\site-packages\\PyQt5\\Qt5\\bin\\Qt5Core.dll', '.'),
        ('C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe', '.'),
        ('C:\\Users\\damon\\PycharmProjects\\device_db_sql\\dist\\Qt5PrintSupport.dll', '.')
    ],
    datas=[('requirements.txt', '.')],
    hiddenimports=['sip', 'mysql.connector'],
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    win_no_prefer_redirects=False,
    win_private_assemblies=False,
    cipher=block_cipher,
    noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE(
    pyz,
    a.scripts,
    a.binaries,
    a.zipfiles,
    a.datas,
    [],
    name='SurvDBManToolTech',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    upx_exclude=[],
    runtime_tmpdir=None,
    console=False,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
)

Is there a mistake in my setup? How can I resolve this "DLL load failed" error for QtPrintSupport?

0

There are 0 answers