0

I'm trying to create an executable from my python GUI script that displays a single image using tkinter.

My objective is to get the image and executable to be one file with the --onefile option in pyinstaller.

Unfortunately this isn't working and I need by image file to be in the same folder as the final executable for it to work. Is there any workaround for this?

1 Answers1

1

PyInstaller brings this functionality and it is well-documented for the folder approach. For example

pyinstaller --add-data 'src/image.jpg:.' myscript.py

will copy the existing file src/image.jpg to the top level of the bundled app (specified as '.').

However how would you do it with a single file (--onefile)? Your script will find the file in a temporary directory: Adding a data file in Pyinstaller using the onefile option

ypnos
  • 50,202
  • 14
  • 95
  • 141
  • Does this mean, the person does not have to copy the image file? Just send the exe alone? Or does it not work with `-F`? – Delrius Euphoria Sep 22 '20 at 23:03
  • 1
    You need to access the bundled file like in the [question](https://stackoverflow.com/questions/51060894/adding-a-data-file-in-pyinstaller-using-the-onefile-option). – acw1668 Sep 23 '20 at 00:35
  • @acw1668 Providing the real answer in a comment ;) – ypnos Sep 23 '20 at 06:52