Python to EXE Converter

In this article we are going to talk about Python to EXE Converter, also we will learn how you can create installer for your application. for converting Python script to EXE we are going to use pyinstaller library, and for making installer we want to use inno setup application. pyinstaller is a library that you can use for building Python to EXE Converter.

 

 

Learn More on PyQt5

 

 

 

 

Installation

First of all you need to install pyinstaller, you can use pip for the installation.

 

 

Python to EXE Converter

OK in this example we are going to create a GUI application using PyQt5, so PyQt5 is a binding for Qt5 C++ a GUI framework for C++ programming language, PyQt5 is used to write all kinds of GUI applications, from accounting applications, to visualization tools used by scientists and engineers. it is possible to write PyQt5 applications that are just tens of lines long, and medium-size projects of 1000 to 10000 lines are very common. if you are not using PyQt5 you can use another Python GUI Libraries like TKinter, Kivy or wxPython. 

 

 

 

Basically this is a simple code for creating of a basic window in PyQt5, we want to first Convert this Python script to EXE and after that we make an installer for our application using InnoSetup.

 

 

 

Now let’s convert this PY file to EXE, first of all you need to copy this file in your Scripts folder.

Python to EXE Converter
Python to EXE Converter

 

 

 

and after that run this command, make sure that you have also copied an icon in the Scripts folder.

 

 

What to generate Option 

-D--onedir Create a one-folder bundle containing an executable (default)
-F--onefile Create a one-file bundled executable.
--specpath DIR Folder to store the generated spec file (default: current directory)
-n NAME--name NAME
Name to assign to the bundled app and spec file (default: first script’s basename)

 

 

 

Windows and Mac OS X specific options

-c--console--nowindowed
Open a console window for standard i/o (default). On Windows this option will have no effect if the first script is a ‘.pyw’ file.
-w--windowed--noconsole
Windows and Mac OS X: do not provide a console window for standard i/o. On Mac OS X this also triggers building an OS X .app bundle. On Windows this option will be set if the first script is a ‘.pyw’ file. This option is ignored in *NIX systems.
-i <FILE.ico or FILE.exe,ID or FILE.icns>--icon <FILE.ico or FILE.exe,ID or FILE.icns>
FILE.ico: apply that icon to a Windows executable. FILE.exe,ID, extract the icon with ID from an exe. FILE.icns: apply the icon to the .app bundle on Mac OS X

 

 

 

After that you will have two directory in your Scripts folder.

Python to EXE Converter
Python to EXE Converter

 

 

 

 

Also you can find the exe file in the dist folder.

Python to EXE Converter
Python to EXE Converter

 

 

 

How to Convert our EXE to Setup Installer 

OK sometimes you need to create an installer for your application, for example you have created your application and you want to sell that application or you want to give that for your friend, for this you want to create an installer that they can install your application in their computers, for creating of installer we need to use InnoSetup.

 

 

Now make two folders and copy your two directories of dist and build, paste
that in your created second folder. also copy your icon in that folder like this.

Python to EXE Converter
Python to EXE Converter

 

 

 

Now open your InnoSetup, from File choose New and after that you need to add your application information that you want to make setup installer.

Python to EXE Converter
Python to EXE Converter

 

 

 

After that click on next, there will be another page of Application Folder, you don’t need to bring changes in their, just click on next. Now we have Application Files page, in here in the Application main executable you need to Browse your exe file from the folder that you have already copied. after that click on the Add Folder and you need to add your main folder that includes the dist and build folders.

Inno Setup Add Folder
Inno Setup Add Folder

 

 

 

Than click on next you will see Application Shortcut page, you don’t need to bring any changes in their, just click on next.

Inno Setup Shortcut
Inno Setup Shortcut

 

 

 

after that there will be Application Documentation, like you can add license and before installation instructions for the application, iam not going to give any documentation for the application so just click on next if you don’t want.

Application Documentation Inno Setup
Application Documentation Inno Setup

 

 

 

Don’t bring any change in the setup install mode page click on next.

Setup Install Mode Inno Setup
Setup Install Mode Inno Setup

 

 

 

 

After that choose your language and click on next, now you need to give the compiler output folder also add your icon in here.

Inno Setup Compiler Setting
Inno Setup Compiler Setting

 

 

 

Click on next and finish, now you are done and you have a setup for your application, you can install that on your computer and  you can give the installer for your friends, they install the application and use from that.

 

 

Leave a Comment