1

I am making a python program which has a nice GUI which uses a lot of images and a icon I want to share this program with my friends by converting it to.exe but the .exe file doesnt work on their computers as they don't have the images and it usually throws an error in powershell like "icon.ico" not defined and stuff like that

Does anybody know a method in which I can convert .py to .exe with the images in the file or just a sort of a workaround towards this issue as I just want to send this file to my friends

  • pyinstaller is a good way to go. For the error about 'icon.ico', check the docs to see how to link to an icon-file correctly. I have had several issues with pyinstaller due to tkinter/pyqt, which also causes confusing errors sometimes. – Niels Henkens Jun 28 '21 at 18:15
  • For regular Python scripts you can often locate image or other data files by assuming where they are relative to the path to the script which is in `__file__`. You can do the same sort of thing with pyinstaller, but you can't use `__file__` — what you want to use instead is in the [documentation](https://pyinstaller.readthedocs.io/en/stable/runtime-information.html). – martineau Jun 28 '21 at 18:46
  • There will be a `.spec` file created after you run pyinstaller command, you will need to edit that, specifying the location of files such as images and icons, then again run pyinstaller for that spec file, this will give you a `.exe` file embedded with those files. Ref: https://stackoverflow.com/questions/31836104/pyinstaller-and-onefile-how-to-include-an-image-in-the-exe-file – Kartikeya Jun 29 '21 at 02:49

0 Answers0