X
X
xomiles2020-08-05 21:52:00
Python
xomiles, 2020-08-05 21:52:00

How to compile a python project with pyinstaller so that the pictures used in the script are also compiled?

When I compiled the script, it only runs in the folder with pictures that are used in the script.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Ternick, 2020-08-05
@xomiles

1) No need to carry nonsense like this: "How to compile a python project ..."
1.1 Python is an interpreted language and cannot be compiled AND CANNOT !!! It can only pack, but that's another story.
1.2 Pictures can be packed next to you easily and simply.
2) In pyinstaller, if you set the --onefile flag, then you can also set the flag to add a file to the archive, something like this:

pyinstaller --onefile --add-data "logo.jpg;logo.jpg" main.py

Now in more detail about this thing: " FILE_NAME_IN_DIRECTORY
; FILE_NAME IN ARCHIVE WITH main.py"
For example:
pyinstaller --onefile --add-data "imgs\logo.jpg;imgs\logo.jpg" main.py

If you didn’t mess up anything, then everything is so :)
If the answer suits you, mark the answer as a solution.

G
gresaggr, 2020-08-11
@gresaggr

There is a visual version:
pip install auto-py-to-exe
After installation on the command line:
auto-py-to-exe
And already in the running application, you can add the necessary files to the script file.
PS Don't forget to select - One file for packing into one file.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question