问题
I use command that:
pyinstaller.exe --icon=test.ico -F --noconsole test.py
All icons do not change to test.ico
Some icons remain default(pyinstaller) icon...
Why?
all icon change OS -> windows 7 32bit, windows 7 64bit(make exe file OS)
remain default icon OS -> windows 7 64bit(other PC)
回答1:
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
回答2:
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.
回答3:
Below command can set the ICON on executable file. Remember the ".ico" file should present in the place of path given in "Path_of_.ico_file".
pyinstaller.exe --onefile --windowed --icon="Path_of_.ico_file" app.py
For ex: app.py file present in current directory and 'app.ico' is present inside the 'Images' folder which is created in current directory. So the command should given below. The final executable file will be generate inside the 'dist' folder.
pyinstaller.exe --onefile --windowed --icon=Images\app.ico app.py
回答4:
Here is how you can add icon while creating exe file from python file-
open command promp from where python file exist and 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 icon. It really works. I am 100% sure.
来源:https://stackoverflow.com/questions/29291113/pyinstaller-setting-icon