1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] EXE created with Pyinstaller fails to import qtmodern as specified in hook

Discussão em 'Python' iniciado por Stack, Setembro 17, 2025.

  1. Stack

    Stack Membro Participativo

    I’m trying to create an EXE based on a Python project. I am using the following command from within a Poetry virtual environment in Powershell on Windows 11: pyinstaller --onefile --additional-hooks-dir=hooks main.py. The generated EXE fails with the following message:

    Traceback (most recent call last):
    File "main.py", line 4, in <module>
    ModuleNotFoundError: No module named 'qtmodern'
    [PYI-11344:ERROR] Failed to execute script 'main' due to unhandled exception!


    main.py, line 4: import qtmodern.styles

    The hooks folder is located within the folder that contains main.py. It contains a single file, hook-qtmodern.py, with the following contents:

    from PyInstaller.utils.hooks import collect_data_files

    datas = collect_data_files("qtmodern", includes=["**/*.qss"])

    from PyInstaller.utils.hooks import collect_data_files

    datas = collect_data_files("qtmodern", includes=["**/*.qss"])

    hiddenimports = [
    "qtmodern.styles",
    "qtmodern.windows",
    ]


    Does anyone know what I am missing or have advice about how to tackle this issue?

    Edit: I noticed there is a Qt folder within the project with a bunch of files that appear to work in pairs: a _ui.py and a matching .ui.

    Continue reading...

Compartilhe esta Página