PyInstaller can't change the shortcut icon

Angelo Uknown picture Angelo Uknown · Jun 23, 2014 · Viewed 8.4k times · Source

My problem is the following, while i can set any icon i like on the executable itself, i cannot change this one

enter image description here

I have tried everything but when i select the exe file or when i create a shortcut this PyInstaller icon will come up!

Here is how the exe looks itself

enter image description here

Here is the tricky part, this DOES NOT happen if i set the option --onefile. If i generate the stand-alone exe, this "additional" unwanted icon goes away!

and here is the spec file in case you need it:

# -*- mode: python -*-
a = Analysis(['Backpack.py'],
             pathex=['C:\\Users\\Angelo\\Desktop\\PyInstaller-2.1\\Backpack'],
             hiddenimports=[],
             hookspath=None,
             runtime_hooks=None)

a.datas += [('back_ico_3.ico', 'C:\\Users\\Angelo\\Desktop\\PyInstaller-2.1\\back_ico_3.ico', 'DATA')]

pyz = PYZ(a.pure)
exe = EXE(pyz,
          a.scripts,
          exclude_binaries=True,
          name='Backpack.exe',
          debug=False,
          strip=None,
          upx=True,
          console=False , icon='back_ico_3.ico')
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=None,
               upx=True,
               name='Backpack')

Answer

Fred picture Fred · Oct 11, 2015

I had this same problem, even when using --onefile. Cutting and pasting the .exe into a fresh directory worked.

Try deleting IconCache.db and rebooting if it still doesn't display your custom icon. It's in %localappdata%.