How do I include files with pyinstaller? How do I include files with pyinstaller? tkinter tkinter

How do I include files with pyinstaller?


Sorry, I thought that only -F/--one-file makes such behavior, but looks like any bundling with pyinstaller needs such changes.

You need to change your code like this, as explained in this answer:

import sysif getattr(sys, 'frozen', False):    image = PhotoImage(file=os.path.join(sys._MEIPASS, "files/bg.png"))else:    image = PhotoImage(file="files/bg.png")

And then bundle it with pyinstaller like this:

pyinstaller --clean -y -n "output_name" --add-data="files\bg.png;files" script.py