[Python] How to set flags in nuitka to add resources to standalone exe?

Discussão em 'Python' iniciado por Stack, Agosto 1, 2025.

  1. Stack

    Stack Membro Participativo

    I need to compile a Python program in nuitka so that the output is one exe file with resources packed inside. I tried setting the --include-data-dir flags and all that stuff, but the compiled executable crashes if I move it to another location, saying resource files were not found.

    This is what the directory looks like where all the files are located:

    client/

    fnt/

    #here fonts

    img/

    #here images

    util/

    #here modules

    icon.ico

    main.py


    In the terminal, being in the client folder, I set the directives:


    py -m nuitka --standalone --onefile --include-data-dir=fnt=fnt --include-data-dir=img=img --windows-icon-from-ico=icon.ico main.py
    ​

    Also I tried this:


    py -m nuitka --standalone --onefile --include-data-dir=../client/fnt=fnt --include-data-dir=../client/img=img windows-icon-from-ico=icon.ico main.py
    ​

    All the same, the program crashes and asks for files nearby.

    I need to build a completely self-contained exe that doesn't require external dependencies.

    What am I doing wrong?

    P.S. Util is only .py files, they are compiled normally. With icon also no problems.

    Continue reading...

Compartilhe esta Página