How to Deploy your Python Code with Inno Setup

Deploying your Python application is a crucial step in making it accessible to users. One popular tool for creating installers on Windows is Inno Setup. In this blog post, we’ll guide you through the process of how to deploy your Python code using Inno Setup, making it easy for users to install and run your application on their Windows machines.


What is Inno Setup?

Inno Setup is a free, script-driven installation system created in Delphi. It simplifies the process of creating professional Windows installers for your software. With Inno Setup, you can package your Python application into a standalone executable installer that handles the installation and configuration of your software on the user’s system.

Despite being introduced almost 30 years ago, back in 1997, it is still one of the most popular and widely used options.


Step 1: Install Inno Setup

Before we start, make sure you have Inno Setup installed on your development machine. You can download it from the official Inno Setup website. Install the software with the default settings.

Download Inno setup

After a successful installation, you should see the following window:

Click on finish, and proceed with the article.


Step 2: Organize Your Project

Ensure that your Python project is well-organized with all the necessary files, including your Python scripts, images, configuration files, and any dependencies.

Here is a the file structure of a sample project:

YourProject/
│-- main.py

│-- images/
│   └-- logo.png
│-- requirements.txt

Run any final tests, and make sure everything is working before you proceed any further. The last thing you want is trying to figure out what went wrong with the setup and compilation process, when the actual problem was within your code.


Step 3: Freeze Your Python Code

Use a tool like PyInstaller or cx_Freeze to freeze your Python code into an executable.

For example, if you are using PyInstaller, run the following commands:

>> pip install pyinstaller
>> pyinstaller --onefile main.py

This will create an output file which stores your exe. In case of any issues with Pyinstaller, refer to the following troubleshooting guide.


Step 4: Open Inno Setup

Open up your installed Inno setup window, and begin following these steps:

1. When you open the software, you will be greeted by a welcome window. Click on the “create a new script file using the Script Wizard” option, and click Ok.

2. On the next window, leave the checkbox blank, and continue by clicking “next”.

3. Fill in the required information in the next window, and then proceed.

How to Deploy your Python Code with Inno Setup

4. You can leave this window’s settings on default, unless you have a good reason for changing them. Application destination folder determines where your application will be installed (on your user’s PC). Keeping the tick-box on, allows the user to change this destination (recommended).

How to Deploy your Python Code with Inno Setup

5. Click the browse option to locate the exe produced in Step3 (with pyinstaller or any other equivalent library). If you have a single executable, and no other supporting files, images, or assets, you can proceed to the next window. Otherwise (as is usually the case) you might have images, supporting DLL’s, or other files produced during the freezing (compiling) process. Add these files (not including the .exe) using the Add file(s) and Add folder option.

How to Deploy your Python Code with Inno Setup

Step 6: Click on the edit button (below add folder) and change the destination path for the _internal folder to “_internal”. If you do not do this, Inno Setup will take all the files from the _internal folder, and paste them within the base directory. This is not what we want, as our exe is expecting to see a _internal folder in the base directory.

Step 7: Continue ahead until you reach the following window, where you will include any EULA agreements, licenses, or other essential information (if any).

Step 8: Continue ahead, changing options and settings as required (most of it is non-essential, or only for very specific cases, or advanced users). If you don’t know what to do, leave it at the default settings.

Step 9: Click the finish button, after which your setup will begin compiling. It will also present you with an option for saving the “script”, which allows you to avoid this entire hassle of going through the setup wizard for a recompilations. You can compile using the script using the option presented to you in step 1 of this process.

Step 10: View your output file, and distribute it to your users.


Now what?

Now you can try installing this software on your own PC to try it out. Ideally, you should find some beta-users (or use another device of yours) to test out the software. Make sure the device/user does not have Python installed to ensure it works for those who do not have Python installed.

Good luck!


This marks the end of the “How to Deploy your Python Code with Inno Setup” Tutorial. Any suggestions or contributions for CodersLegacy are more than welcome. Questions regarding the tutorial content can be asked in the comments section below.

Subscribe
Notify of
guest
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments