PyInstaller can't change the shortcut icon
Asked Answered
G

3

9

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')
Gehman answered 23/6, 2014 at 10:32 Comment(0)
A
13

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%.

Affrica answered 11/10, 2015 at 10:56 Comment(1)
Cutting and pasting the .exe into a fresh directory worked for me too!Lightface
N
5

Enable Hidden Items

Go to C:\Users\User\AppData\Local\Microsoft\Windows\Explorer. Select all files that begin with iconcache and thumbcache and delete all these files

Go to C:\Users\user\AppData\Local and delete IconCache.db

Nofretete answered 31/3, 2020 at 12:49 Comment(1)
Need to restart Explorer in task manager before the icons change.Herv
U
0

Have you tried:

exe = EXE(pyz,
      a.scripts,
      exclude_binaries=True,
      name='Backpack.exe',
      debug=False,
      strip=None,
      upx=True,
      console=False , icon='C:\\Users\\Angelo\\Desktop\\PyInstaller-2.1\\back_ico_3.ico')
Unijugate answered 12/8, 2015 at 13:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.