Pyinstaller setting icons don't change

PythonIconsPyinstallerExecutable

Python Problem Overview


When I use the command:

pyinstaller.exe --icon=test.ico -F --noconsole test.py

All icons do not change to test.ico. Some icons remain as the pyinstaller's default icon.

Why?

All icon change in

  • windows 7 32bit
  • windows 7 64bit (make an exe file OS)

Some remain default

  • windows 7 64bit (other PC)

Python Solutions


Solution 1 - Python

I know this is old and whatnot (and not exactly sure if it's a question), but after searching, I had success with this command for --onefile:

pyinstaller.exe --onefile --windowed --icon=app.ico app.py

Google led me to this page while I was searching for an answer on how to set an icon for my .exe, so maybe it will help someone else.

The information here was found at this site: https://mborgerson.com/creating-an-executable-from-a-python-script

Solution 2 - Python

I think this might have something to do with caching (possibly in Windows Explorer). I was having the old PyInstaller icon show up in a few places too, but when I copied the exe somewhere else, all the old icons were gone.

Solution 3 - Python

The below command can set the icon on an executable file.

Remember the ".ico" file should present in the place of the path given in "Path_of_.ico_file".

pyinstaller.exe --onefile --windowed --icon="Path_of_.ico_file" app.py

For example:

If the app.py file is present in the current directory and app.ico is present inside the Images folder within the current directory.

Then the command should be as below. The final executable file will be generated inside the dist folder

pyinstaller.exe --onefile --windowed --icon=Images\app.ico app.py

Solution 4 - Python

I had similar problem. If no errors from pyinstaller try to change name of .exe file. It works for me

Solution 5 - Python

Here is how you can add an icon while creating an exe file from a Python file

  • open command prompt at the place where Python file exist

  • type:

    pyinstaller --onefile -i"path of icon"  path of python file
    

Example-

> pyinstaller --onefile -i"C:\icon\Robot.ico" C:\Users\Jarvis.py

This is the easiest way to add an icon.

Solution 6 - Python

That's error of a module in pyinstaller. The stuff would be sth like this, right:

File "c:\users\p-stu\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\utils\win32\icon.py", line 234, in CopyIcons
    except win32api.error as W32E:
AttrubuteError: module 'win32ctypes.pywin32.win32api' has no attribute 'error'

Solution 7 - Python

if you want to set the default icon, not the one pyinstaller sets for you there is an option while building EXE just add "-i NONE" in command.The default os icon will be applied to your executable.

pyinstaller --onefile --clean -i NONE --noconsole

reference https://pyinstaller.readthedocs.io/en/stable/man/pyinstaller.html#windows-and-mac-os-x-specific-options

Solution 8 - Python

In my case, the new icon of the file did not show up in the dist folder but appeared only when I moved the icon on the Desktop.

Solution 9 - Python

pyinstaller --clean --onefile --icon=default.ico Registry.py

It works for Me

Solution 10 - Python

Just change the name of the file in the File Explorer.I was facing same issue but after changing the name of .exe file the icon i mentioned during pyinstaller command appeared.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSomputerView Question on Stackoverflow
Solution 1 - PythonSludgeView Answer on Stackoverflow
Solution 2 - PythonAlan LView Answer on Stackoverflow
Solution 3 - PythonAvinash PoshiyaView Answer on Stackoverflow
Solution 4 - PythonАнтон СмирновView Answer on Stackoverflow
Solution 5 - PythonAbhisek UpadhayaView Answer on Stackoverflow
Solution 6 - Pythonuser13518412View Answer on Stackoverflow
Solution 7 - PythonBhavesh AudichyaView Answer on Stackoverflow
Solution 8 - PythonNicola SpanuView Answer on Stackoverflow
Solution 9 - PythonLilDavidView Answer on Stackoverflow
Solution 10 - PythonSahil GomesView Answer on Stackoverflow