Search code examples
pythonpython-3.x32-bitpyinstaller

PyInstaller fails to include icon


I am using PyInstaller (V3.1.1) to compile my program on Windows 7 64-bit. This works fine:

pyinstaller --onefile --version=version.txt program.py

This fails:

pyinstaller --onefile --version=version.txt --icon=icon.ico program.py

The error is the same as when I run:

>>> import win32api
>>> src = "C:\\path\\to\\icon.ico"
>>> win32api.LoadLibraryEx(src, 0, 2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
pywintypes.error: (193, 'LoadLibraryEx', '%1 is not a valid Win32 application.')

I have established that I have 32-bit python (3.5.1) installed:

>>> import platform
>>> platform.architecture()
('32bit', 'WindowsPE')

All other solved questions relating to this seem to be solved by installing 32-bit python. All modules were installed using pip.


Solution

  • I found out the .ico file I was using was corrupt. Having used another online converter (.png -> .ico with all sizes in one file) the exe compiles successfully.