How to Create an MSI for a Python Application

Written by Alex Marin · March 3rd, 2021

As one of the most prominent programming languages in the world, Python is supported by many tools and modules. It is easy to learn and provides a nicely constructed code -- which opens the door for many solutions and endless possibilities.

In this particular article, we will go through creating an MSI for your Python application, using the free edition of Advanced Installer. It will take us only 5 steps!

Before diving into our quick guide on creating an MSI for a Python application, let's address the process of converting Python into Exe.

How to Convert Python into Exe

In the past, it was required for a user to have Python installed in order to run a Python script, but nowadays there are many Python to exe converters in the market.

NoteThe most popular ones are PyInstaller , or Auto Pi to EXE, which is basically a graphical user interface for PyInstaller.

When a Python script is converted into an EXE, all of the necessary Python dependencies and dll’s are added, either in one big exe file, or alongside the executable.

These converters ensure the developers that no matter where the script is executed, all of the necessary Python files will be present on the machine -- to make the script execute successfully.

If you want to read or refresh on how to deploy a Python script, you can check our post about it -- but, now let’s have a look at how easy it is to create an MSI for a converted Python script.

How to Create an MSI for your Python executable

For this example, we converted a simple helloworld Python script to exe using the Auto PI to EXE converter. We also chose to leave all of the python files uncompressed (this doesn’t affect our Advanced Installer project).

Now that you have your Python executable follow these steps:

1. Open Advanced Installer. You will be presented with a dialog window where you can choose the type of project you want to create.

2. Select the “Simple” type.

3. Uncheck the “Use wizard...” option.

4. Press the [ Create Project ] button.

5. Your new project has been created, which means you can now edit it.

Once the project is opened, navigate to the Files and Folders Page. There, you will be able to choose where to install your files. In our case, we added all the files to “Program Files\My Python Application”.

If you want to add a shortcut to your executable (in our case helloworld.exe), select your executable, and press “New Shortcut To” from the upper left corner, then select “Installed File”.

A new window will appear where you can configure your shortcut name, icon, etc. For more information about shortcuts see our Creating Shortcuts in the Files and Folders Page.

Once all of our files and shortcuts are created, we can build the MSI by clicking on Build in the upper left corner.

And that is it, in a few simple clicks you have your Python application ready for deployment.

Conclusion

Advanced Installer offers quick solutions for multiple Python scenarios, whether you want to "wrap up" your Python script, or if you are using tools to convert your Python script to EXE.

You could also convert your Python script to EXE and automatically create an MSI installer for it with cx_freeze . You can read more about this tool here: Create a Python executable and MSI installer using Cx_freeze.

NoteCX_Freeze reminds me of WiX, because the MSI must be created programmatically.

As always, we hope you found this article useful, let us know your own tips and tricks in the comments.

Comments: