I have written a small program in tkinter
in python 3.5
I'm making executable out of it using pyintaller
I have included a custom icon to the window to replace default feather icon of tkinter
from tkinter import *
from tkinter import messagebox
import webbrowser
calculator = Tk()
calculator.title("TBE Calculator")
calculator.resizable(0, 0)
iconFile = 'calculator.ico'
calculator.iconbitmap(default=iconFile)
icon works fine when running program.py
file directly
But when making it executable using
pyinstaller --onefile --windowed --icon=program.ico program.py
and running program.exe from dist directory, it gives error as
failed to execute script program
I also tried with
pyinstaller --onefile --windowed --icon=program.ico --add-data="calculator.ico;ico" program.py
But still same error.
program.spec file
# -*- mode: python -*-
block_cipher = None
a = Analysis(['program.py'],
pathex=['C:\\Users\\anuj\\PycharmProjects\\YouTubePlayer\\Program'],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name='calculator',
debug=False,
strip=False,
upx=True,
console=False , icon='program.ico')
Removing the line calculator.iconbitmap(default=iconFile)
works fine but with default feather icon.
How to include window icon file with .exe executable?