Convert Python Script to exe File | Faster than PyInstaller | Quick Startup | Windows Installer

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey hello guys so today we are going to see how you can convert or convert your python script to a executable windows installer file that is the file with the common extension.exe and for this there's a common way which is to use this pi installer command using the dash f or double dash one file flag but uh even though this creates a single executable file the problem is that that file which pines folder creates will really will take a really long time to start up because uh uh since all files are packed into that single file it's gonna you the that file actually needs to unpack all the link libraries and the other dependencies to a temporary folder before actually executing your code in that file so even printing a simple hello world is gonna take like 10 seconds so today we are going to look at a different approach to solve this problem and also get a single executable file first we'll begin by using pi installer but we won't use that single file command or that flag so uh in the directory at which your python script is present you can launch the command from there and then uh you will type this command which is the usual pi installer command to create exe files but we won't be using that uh single file flag and uh since my uh python script is a uh is a gui file uh with a graphical user interface i i'll use this w flag to indicate that i don't need a console and then i i also have a icon over here but for now i'm not going to use the icon and then you will type my script name which is main.pi so this should create a list of files associated with our script and uh this is assuming that you have pi installer installed in your pc if not you can use uh install by installer using the simple command or pip installed by installer oops flip install rate sorry in some thought i typed simple because it was a really simple command okay so i already have this pi installer but in case you do not have pi installer you can install using this command flip install by installer so now that uh we'll be having our file inside this dist folder inside the and this file will be the this file's name will be the same as your script name which is in this which in this case is main so inside this you can get this single executable file but the problem is that this won't work independently without all these associated files so somehow we need to compile all these files and still uh get a single executable file uh this file uh will actually load pretty fast but in case if you had used this uh a single file flag to create a single executable file with pi installer that would take a really long time to start so now we look at how we can compile all these files into a single executable installer file that is will be using uh windows installer like program so that we can install that program in in our computer and like say we can create a shortcut in our desktop for this main executable file so that we can just log when we click the shortcut it will launch this main executable file and uh our program will also launch pretty fast so for that we need uh this program called inno setup compiler you can search for this online and uh you you can go to this website i'll give a link to the website in the description below then we go for the download section and then i really i download this uh file from you can download from any server you want i'll download from this link so after you've got this file uh it's a it's a exe file so it's gonna install like any other program uh so you need to install this program and after installing this program uh you can start that program so after you start after you install and open this program it's going to give a screen like this you can just click cancel and then go to file and new and then you can click on next here you can give a name to your program for now i'll call it tasks and you can set over you can set the version of your program and you can set the publisher name or your name and in case uh you have any linked website your script you can give that pro give that url over here and then we can move on and uh you can leave these options to default it's actually uh the folder at which your for your file is gonna be executed sorry your file is gonna get uh unzipped or extracted it's by default the program files folder and the c drive you can just leave it to default and now we need to select the main executable file of our program which in this case is this guy right here main.exe so we need to choose him you can uh give browse and choose this uh main.exe or whichever whatever name you you've got you have saved for your program so i'll choose this main.exe the icons are a bit different i think it's because uh due to icon cache windows has cached icon over there but the real icon is this guy so you choose this main you choose this main executable file from this distribution folder and then we need to add this main file uh to this uh application so you you click you should click on add folder and then choose a specific folder which uh this specific folder uh the folder with the name which will be the same as the name as your script so in this case since my script is called main.pi uh you nee i need to select this main folder from here so it's in d drive so i'll choose file and distribution and then i'll choose this main folder and then i need to include all the subfolders so i'll click yes now and then you can move on to the next uh you can uh this is for file association for my script my script does not have any file associations with the extension so i i'll uncheck this and move on to the next one this is uh creating shortcuts so you can allow the user to create a desktop shorter desktop shortcut as well as a shortcut in the start menu and then we will move on to the next step in case you have any licenses you can choose over here i don't have any and this is for administrative install installs it for the all the users are using that specific computer if you need to install only for that specific user which is who is currently logged on you can choose this option we'll go with admin state of install and then you can choose your language and this is the installer main now we need to choose where our installer file is gonna get outputted so i'll choose my desktop over here and then you can give a name to the setup file it's gonna be a installer file the dot exe file so i'll say task setup remember this is not the main file for your program this is gonna be the file which is gonna install it for in your computer so and in in case you have a icon you can choose it uh now so i'll choose that icon which i had over there and then we can you if you want you can set a password for your installation then we will move on and then you can just leave this to default and this should uh now you can compile that script you can click on no for this so it's now compiling all those files into a single installer file so now it has compiled that all the all those files into a single executable windows installer file now we will now since we saved it in our desktop we'll be having so here is our setup file uh this is like any other normal windows installer file you can just click on it to install that uh install your program uh you can change where you want your program to be installed i'll leave it to default and i want a desktop shortcut okay so we are installing our python script as a windows program with dot exe file so we are done with it so here is our program i didn't set any icon to my program if you want you can set it using uh while you are using that uh pi installer command line uh option so i launched my program okay so yeah it was pretty fast but in case you were using that uh single line of file dash of flag use in pi installer i'm sure it won't be it won't start up this fast so this is a alternate approach and a better approach to convert your python scripts to exe files so that's all for this video thank you for watching and hope to see you in the next one
Info
Channel: catglue
Views: 21,772
Rating: 4.7767859 out of 5
Keywords:
Id: srT5COWpQlc
Channel Id: undefined
Length: 9min 27sec (567 seconds)
Published: Fri Jan 08 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.