I am having trouble packaging my python Tkinter GUI file into a .exe executable file with py2exe. When I finish building the application through the command prompt and open the .exe application that was converted, I get the error:
Traceback(most recent call last):
File "Gui.py", line 15, in <module>
File "Tkinter.pyc", line 1624, in wm_iconbitmap
_tkinter.TclError: bitmap "TSicon.ico" not defined
How do I get py2exe to be able to function with the images that I put into my Tkinter Python file and successfully convert my python file to .exe executable.
It seems the problem is that the TSicon.ico is not copied to the same folder where the .exe file resides. Assume that the python file and TSicon.ico are in the same folder. Then, you setup.py should look like this:
from distutils.core import setup
import py2exe
data_files = [('', [r'TSicon.ico'])]
setup(
windows =['tk_with_image.py'],
data_files = data_files,
options={
}
)
Now the .exe file and the TSicon.ico will be in the same folder (dist), and everything should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With