I am following a step by step tutorial on PySide6 and PyInstaller in order to do my first one-file build EXE application.
But I am stuck at the step "Setting an application icon". My window created with PySide6 doesn't display my logo icon when I build the source file with PyInstaller.
I have used app.setWindowIcon(QtGui.QIcon(os.path.join(os.path.dirname(__file__) , 'logo.ico')))
as described on the PySide6 tutorial to pass through relative path but it didn't work.
Then I have replaced os.path
with ntpath
because I am on Windows but it didn't work too.
I have tried with
str(Path(__file__).parent / 'logo.ico')
from pathlib but no more result either.
All of this path shows correctly the logo icon when I execute app.py from my IDE. However, when I build it with PyInstaller using this command pyinstaller --onefile --icon=logo.ico -w .\app.py
, and launch app.exe there is no logo on my window. I don't know if path to my logo is the problem here but I don't see what else it could be.
Ok so as mentioned by @musicamante, I need to bundle my icon as a resource : pyinstaller --windowed --icon=hand.ico --add-data="hand.ico;." app.py
or by modifying the datas list in the Analysis section of the spec file.