How To Add An Icon Of My Own To A Python Program

You can't add a custom icon to a plain Python script, but if you convert it to a Windows executable using py2exe, you can specify icon resources to use for it. There's a how-to on their wiki.


There are two steps: first build the Python executable. For this you will need something like py2exe, "which converts Python scripts into executable Windows programs, able to run without requiring a Python installation."

Then once you have your executable, to give it an icon, you can use the answer to this question: Add icon to existing EXE file from the command line for that finishing touch.


@dmitri's solution works but Py2Exe stopped development at python 3.4 and will not work with newer versions PyInstaller would also do this.

pip install pyinstaller
pyinstaller --onefile --windowed --icon=youricon.ico yourprogram.py

Python version 3.7.3.

Tags:

Python