Add image to .spec file in Pyinstaller

Does anyone know how to modify a file .speccreated using Makespec.pyPyinstaller to include image data in _MEIPASS2Temp dir? I want to add an icon to my exe. I did what I wrote here , but I just don’t know how to add my data to .spec.

I add this line to the end of the file .spec:

a.datas += [('iconName.ico','DATA','C:\\Python26\\pyinstaller-1.5.1\\iconName.ico')]
+5
source share
3 answers

Here is my spec ( Collector.spec) file that I used for a simple python program called "Collector.py".

# -*- mode: python -*-
a = Analysis(['Collector.py'],
             pathex=['C:\\Users\\vijay\\Python\\Collector'],
             hiddenimports=[],
             hookspath=None,
             runtime_hooks=None)
a.datas += [('logo.png','C:\\Users\\vijay\\System\\icon\\logo.png','DATA')]
pyz = PYZ(a.pure)
exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          name='Collector.exe',
          debug=False,
          strip=None,
          upx=True,
          console=False , icon='C:\\Users\\vijay\\System\\icon\\logo.ico')

"a.datas += .... " pyz png-, GUI. "icon=....", exe, ico, Windows .

, (Collector.py, ).

script Collector.py, Max :

path = self.resource_path("logo.png")
icon = wx.Icon(path, wx.BITMAP_TYPE_PNG)
self.SetIcon(icon)

, pyinstaller Collector.spec, .

, !

+7

, :

python Makespec.py --icon=<FILE.ICO> yourprogram.py

exe = EXE(...)

icon=<FILE.ICO>

file.ico ( Windows), . a.datas, , , sys._meipass. , , .

+2

This line must be added between a = Analysis(...)and pyz = PYZ(a.pure).

0
source

All Articles