pythoniconspyinstaller.ico

PyInstaller EXE Changes Back To Original Icon


I have created a standalone .exe file with PyInstaller using this command: pyinstaller --onefile -i "icon0.ico" test.py -w. When I open the dist folder the exe gets put into it shows the icon I used but the moment I copy or move it from that folder the icon disappears and it returns back to the stock PyInstaller icon.

Oddly enough if I rename the file the icon stays like it is supposed to, but I can't use this as a solution since I have other files that depend on my exe being a specific filename. I used Resource Hacker to view the icon contents, I completely replaced the stock icon with my icon but after saving it nothing changed, still the same old stock PyInstaller icon. Yes, my .ico file had all the different 256x256, 128x128, 64x64, 48x48, 32x32 and 16x16 sizes.

What can I do to fix this?

PyInstaller version: 3.4

Python version: 3.7.2


Solution

  • I usually use:

    pyinstaller --onefile -w --icon=*icon name*.ico test.py