Reputation: 1283
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
Upvotes: 81
Views: 269115
Reputation: 7385
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: Creating an Executable from a Python Script | Matt Borgerson (Archive.org)
Upvotes: 135
Reputation: 11
Make sure that the app.ico file is in the same directory of your exe
Upvotes: 0
Reputation: 31
This works for me. Note: main.py and icon.ico files are in same folder.
Command:
pyinstaller --onefile --icon "icon.ico" --name MyApp main.py
Upvotes: 0
Reputation: 21
When I copied the file over to another machine, icons stopped working (I had used --icon=myicon.ico).
So I Right-Click on the exe file/shortcut of the exe file -> Properties -> click “Change Icon” button -> Browse for the .ico file and hit OK,OK
Upvotes: 0
Reputation: 1
its just delete all files in build and dist and repeat the process using: pyinstaller --onefile --icon=default.ico Registry.py
Upvotes: 0
Reputation: 71
Sometimes, the window didnt clear the cache.
need to run this script on the cmd
taskkill /IM explorer.exe /F CD /d %userprofile%\AppData\Local DEL IconCache.db /a explorer.exe
Upvotes: 1
Reputation: 88
Very old tho. I encountered same problem but with additional stuff like it's not really building the application even with some changes of the entry file stopping at INFO: Checking EXE.
I solved this and my problem by deleting the app.spec
and build
folder that was genereated by the pyinstaller
.
The icon is really updated (see the app icon at upper left), window just cached it I think.
Upvotes: 1
Reputation: 71
The solution for me was refresh the icon cache of the windows explorer
for Windows 10: Enter "ie4uinit.exe -show" in Windows run
Link: https://superuser.com/questions/499078/refresh-icon-cache-without-rebooting
Upvotes: 7
Reputation: 21
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.
Upvotes: 1
Reputation: 151
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 <filename.py> --noconsole
Upvotes: 2
Reputation: 101
I had similar problem. If no errors from pyinstaller try to change name of .exe file. It works for me
Upvotes: 10
Reputation: 59
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.
Upvotes: 4
Reputation: 171
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
Upvotes: 17
Reputation: 29
pyinstaller --clean --onefile --icon=default.ico Registry.py
It works for Me
Upvotes: 0
Reputation: 7
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'
Upvotes: 0
Reputation: 2015
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.
Upvotes: 74