[Python] Unable to bundle pyqt5 app with tensorflow_hub

Discussão em 'Python' iniciado por Stack, Junho 28, 2025.

  1. Stack

    Stack Membro Participativo

    I have a pyqt5 GUI app (Selecta) which runs perfectly if I run it as a script Selecta.py or if I compile it with the following spec file:

    # -*- mode: python ; coding: utf-8 -*-
    # from PyInstaller.utils.hooks import collect_data_files

    a = Analysis(
    ['Selecta.py'],
    pathex=[],
    binaries=[],
    datas=[
    ("src/selecta/yamnet-tensorflow2-yamnet-v1", "yamnet-tensorflow2-yamnet-v1"),
    ],
    hiddenimports=[
    "scipy._cyutility",
    ],
    excludes=[],
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    noarchive=False,
    optimize=0,
    )
    pyz = PYZ(a.pure)

    exe = EXE(
    pyz,
    a.scripts,
    [],
    exclude_binaries=True,
    name='Selecta',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    console=False,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
    )
    coll = COLLECT(
    exe,
    a.binaries,
    a.datas,
    strip=False,
    upx=True,
    upx_exclude=[],
    name='Selecta',
    )
    app = BUNDLE(
    coll,
    name='Selecta',
    icon="icon.icns",
    bundle_identifier=None,
    )


    I then tried to compile it into a .dmg using create-dmg. However when I run the .dmg, copy the app to my /Applications dir and open it I get an error:

    Failed to execute script 'Selecta' due to unhandled exception: Op with name ConstructionFails


    I think the error is related to how pyinstaller packages up tensorflow but I'm unsure how to address this. I just want my app to work as an Application the same way it runs as a script.

    Happy to provide further context if needed.

    Continue reading...

Compartilhe esta Página