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
Some remain default
This question is related to
python
icons
pyinstaller
executable
I had similar problem. If no errors from pyinstaller try to change name of .exe file. It works for me
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'
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
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.
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.
pyinstaller --clean --onefile --icon=default.ico Registry.py
It works for Me
Source: Stackoverflow.com