How to add an Icon to Cx_Freeze EXE (correctly)

In this Python tutorial, we will discuss how to add an Icon to our Cx_freeze EXE. The default icon is pretty boring, and not a good look when distributing your application to potential users/clients.


Change Icon in Cx_Freeze EXE

First of all, we are going to need some Icons. We have a folder of about 8 icons over here that you can download and use.

Sample Icons (1361 downloads )

There are two ways to add icons in cx_Freeze, depending on how you compile your builds. If you use the setup script option, then modify the following line in your code.

executables = [
    Executable('graphingapp.py', base=base, 
                target_name = 'graphapp', icon="andriod.ico")
]

You need to add an extra “icon” option, with the filepath/filename to the Icon file.

Now all you have to do is recompile your build using the following command.

python setup.py build

Now if you navigate over to your “build” folder produced by cx_freeze, the EXE will now have a new icon. Here is a screenshot from our device.

add an Icon to Cx_Freeze EXE

As you can see, the Icon has been added successfully.


For those of you using the console to compile your application, add the following option to your command:

--icon="andriod.ico"

This has the same effect, and will add the Icon as shown earlier.


Possible Issues with Icons in Cx_Freeze

As with any feature, there is a good chance that there will be issues in certain circumstances. We have compiled a few common problems here, along with their solutions for your convenience.

Reinstall cx_Freeze

Its possible that you are using an old version of cx_freeze, or there is an issue with your current version. Reinstalling or updating cx_freeze has proven to work for some users (even when they had the latest version).


Bugged Python installation from Microsoft Store

If you installed Python through the Microsoft store, then there is a known issue that occurs when “freezing” (converting to exe) python files. This issue will prevent the Icon from successfully being add, and will throw an error.

The recommended solution to this issue is to uninstall your current version of Python, and install it from the official website.


This marks the end of the How to add an Icon to Cx_Freeze EXE Tutorial. Any suggestions or contributions for CodersLegacy are more than welcome. Questions regarding the tutorial content can be asked in the comments section below.

Leave a Comment