2

i know that pyinstaller --onefile filename.py converts python file to exe, but is it possible to pack additional jpg files to that exe? I mean, i have files like

main.py
image.jpg
image1.jpg

Can i convert it all into main.exe?

1 Answer 1

2

Sure, it is possible. See the doc here.

Basically, what you have to do is:

  • If running pyinstaller on your python script, run:

    pyinstaller --add-data 'image.jpg:.' --add-data 'image1.jpg:.' main.py [Linux]

    pyinstaller --add-data "image.jpg;." --add-data "image1.jpg;." main.py [Windows]

  • If running pyinstaller via a spec file, add to your spec file:

    a = Analysis(...
         datas=[ ('image.jpg', '.'), ('image1.jpg','.') ],
         ...
         )
    

    and run pyinstaller main.spec

Note that, quoting the doc:

The first string specifies the file or files as they are in this system now.

The second specifies the name of the folder to contain the files at run-time.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.