Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pyinstaller: change application icon

First time using pyinstaller, I ran pyinstaller appname.py --icon='myicon.ico' The icon file is converted using convertico.com and it is at the same directory where I ran pyinstaller

In dist/appname/ directory, the executable appname icon is still not changed. Did I do something wrong? The spec file is:

# -*- mode: python -*-

block_cipher = None

a = Analysis(['appname.py'],
         pathex=['/home/admin/appname'],
         binaries=None,
         datas=None,
         hiddenimports=[],
         hookspath=None,
         runtime_hooks=None,
         excludes=None,
         win_no_prefer_redirects=None,
         win_private_assemblies=None,
         cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
         cipher=block_cipher)
exe = EXE(pyz,
      a.scripts,
      exclude_binaries=True,
      name='appname',
      debug=False,
      strip=None,
      upx=True,
      console=True , icon='myicon.ico')
coll = COLLECT(exe,
           a.binaries,
           a.zipfiles,
           a.datas,
           strip=None,
           upx=True,
           name='appname')
like image 518
electro Avatar asked Oct 13 '15 23:10

electro


1 Answers

It has worked, just a problem with cached icons. If you move the .exe to another folder the icon should change. Just to be sure though rebuild using :

pyinstaller --onefile --icon=myicon.ico --clean yourapp.py

The --clean command cleans the cache and your icon will appear correctly

like image 99
Mark Cuddihy Avatar answered Oct 01 '22 21:10

Mark Cuddihy