Convert Python To Exe Files
Key Takeaways
The video demonstrates how to convert Python files to executable files on Windows using the PyInstaller module, covering the installation, script creation, and compilation process. It also discusses the limitations and use cases of creating executable files from Python scripts.
Full Transcript
[Music] what is going on guys welcome back today we're going to learn about something that was highly requested on this channel in the comments section it is how to convert python files into executable files on windows so how to convert dot pi files of py files into exo files exe files and uh this here is one example of how i did it so it's the rsi analysis tool it's one of the previous videos the technical analysis in python i took this script which is quite large when you think about it because it imports matlab lab and pandas and as you can see it takes some time to boot up quite a time to boot up actually but once it's done and once it's loaded the data from the yahoo finance api you can see that we can actually execute the whole program here and this is not a python file being executed this is not a python script it is an executable file it's working on its own it doesn't have anything else it's just the dot exe file um and you can see it has 300 megabytes for what it does that's quite large so what you need to know up front definitely is that creating executable files with python is not an optimal thing to do you can do it but python is still an interpreted language it's not meant to be compiled if you want to have dot exit files if you want to build for example a virus or a key logger it has to be an executable file and run in the background and uh not the script that you can look into you don't want to code it in python you can code it in python sometimes but actually you want to do this in c and c plus plus maybe in c sharp in something that can actually be compiled if you want to have a compiled file obviously now you can still use python for penetration testing and so on but it's a script and you can usually look into a script especially it's an interpreted script so it executes line after line which means that it's supposed to be readable right so today nevertheless we're going to learn how to do this in python how to or actually how to convert python files on windows into executable files even though it's not the most optimal thing to do so let's get right into it so the first thing we're going to do is we're going to open up a command line we're going to type cmd and in here we're going to install the pi installer module using pip if you don't know what pip is if you don't have piv install check out my beginners and intermediate tutorial series on python there i show you how to install it so if you have pip you can just type pip install and the module um in my case i'm also going to activate the anaconda environment here this is an optional step if you're not using anaconda just ignore it just use pip directly but if you're using it you can activate it now and then you say pip install pi installer now in my case it says already satisfied the requirements are already satisfied because i've already installed the module and once you have installed it you can also just go ahead and use it and what you need to do first is you need to navigate the command line to the directory where your python file is in this case we're going to just navigate to the desktop where we are going to create a python file so here we're just going to say new file and we're going to create a i don't know main dot py file and inside of it we're just going to do something very simple just some effect that we can notice for example we're going to say with open uh my file.txt in writing mode plus and sf we're just going to say f dot write hello world so we have this basic effect here this is a very simple script and if we just close this and run this you can see that we get a my file.txt so it has the effect that it creates a file and in this file we can see uh hello world so we're going to delete the file now and we're going to convert this main.py file into an executable file so what we do is we type pi installer and now we have to specify some parameters the first one if you want to uh the first parameter parameter that you specify if you want to is the one file parameter so you type uh minus minus one file and this means that we have one executable file where everything is inside of that file so we don't have dll files or some libraries or some special files everything is in one executable file and you don't have anything else if you want that you specify minus minus one file and then we're also going to say it's windowed just optional since we don't have a gui here it doesn't actually matter um but what we also can do is we can specify an icon and this icon has to be of the file type.ico so dot ico uh and once we have such a file we can say minus i and then specify the icon in this case i can dot ico and this is just a neural nine logo up here it's just a basic icon file that we're going to use and we can then say minus um or actually not minus sorry then we just specify the python script so main.py and then we click enter and what you're going to see is that it starts building and since this is a very basic script very very simple it's going to finish quite fast if it's a very extensive script or a big application it can take many minutes or even hours depending on the size of your program but as i said you should not necessarily be compiling python scripts it's not not what they're not what they're meant to do or to be so once we're done with the building here we get uh those files and directories here actually if we're honest we can dump those three here so we are going to delete them recycle bin emptying uh we're also going to delete the original script so that you see that it's not just calling the script we're just going to delete it completely and inside of the dist folder here inside of the this directory we have main.exe which is um an executable file with the neural nine node logo and when we run it when we double click it first of all my antivirus software starts scanning it and then you can see that it creates my my file.txt where it says hello world inside of it so you can see that the effect is the same we can also move it to the desktop where it does the same thing so just double clicking it creating a file that's it and it's an executable file you cannot read it i can also right click it and open it up with visual studio code and you will see that it's not displayed in the editor because it's binary or uses an unsupported text encoding so we're not able to see what's written in that file we can also uh right click it you can see it's six megabytes so way larger than a basic python script python script is not that large um and you can see the compilation went fine so that's it for today's video if you enjoyed i hope you learned something if so let me know by hitting the like button and leaving a comment in the comment section down below one thing i would like to mention is that this will not always work out for example i tried to compile or to convert the new summarizer that we already built in a video in a previous video i tried to convert it into an executable file it didn't work it just or actually it converted it but i couldn't run it it said failed running script so it just didn't work because probably it was using some complex libraries that were interconnected and you know things go wrong if you compile stuff from an interpreted language it's not what it's meant to do as i already said also the stock analysis tool was 300 megabytes which is way too large for such a simple tool so the fact is that if you want to combine if you want to have compiled programs executable files you don't code in python you use python as a scripting language to do stuff and it's a great language and it can accomplish a lot of tasks but if you want to have executable compiled files you use cpus plus c java whatever you don't use python for that however in today's video i showed you how to do it i i hope you enjoyed it make sure you subscribe to this channel and make sure you hit that notification bell to not miss any videos other than that thank you very much for watching see you in the next video and bye [Music] you
Original Description
In this video we learn how to convert Python files (.py) into executable files (.exe) on Windows.
◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾
📚 Programming Books & Merch 📚
💻 The Algorithm Bible Book: https://www.neuralnine.com/books/
🐍 The Python Bible Book: https://www.neuralnine.com/books/
👕 Programming Merch: https://www.neuralnine.com/shop
🌐 Social Media & Contact 🌐
📱 Website: https://www.neuralnine.com/
📷 Instagram: https://www.instagram.com/neuralnine
🐦 Twitter: https://twitter.com/neuralnine
🤵 LinkedIn: https://www.linkedin.com/company/neuralnine/
📁 GitHub: https://github.com/NeuralNine
🎵 Outro Music From: https://www.bensound.com/
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from NeuralNine · NeuralNine · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Visualizing Stock Data With Candlestick Charts in Python
NeuralNine
Python Beginner Tutorial #1 - Installation and First Program
NeuralNine
Python Beginner Tutorial #2 - Variables and Data Types
NeuralNine
Python Beginner Tutorial #3 - Operators and User Input
NeuralNine
Python Beginner Tutorial #4 - If Statements and Conditions
NeuralNine
Python Beginner Tutorial #5 - Loops
NeuralNine
Python Beginner Tutorial #6 - Sequences and Collections
NeuralNine
Python Beginner Tutorial #7 - Functions
NeuralNine
Python Beginner Tutorial #8 - Exception Handling
NeuralNine
Python Beginner Tutorial #9 - File Operations
NeuralNine
Python Beginner Tutorial #10 - String Functions
NeuralNine
Python Intermediate Tutorial #1 - Classes and Objects
NeuralNine
Python Intermediate Tutorial #2 - Inheritance
NeuralNine
Python Intermediate Tutorial #3 - Multithreading
NeuralNine
Python Intermediate Tutorial #4 - Synchronizing Threads
NeuralNine
Python Intermediate Tutorial #5 - Events and Daemon Threads
NeuralNine
Python Intermediate Tutorial #6 - Queues
NeuralNine
Python Intermediate Tutorial #7 - Sockets and Network Programming
NeuralNine
Python Intermediate Tutorial #8 - Database Programming
NeuralNine
Python Intermediate Tutorial #9 - Recursion
NeuralNine
Python Intermediate Tutorial #10 - XML Processing
NeuralNine
Python Intermediate Tutorial #11 - Logging
NeuralNine
Python Data Science Tutorial #1 - Anaconda and PyCharm Setup
NeuralNine
Python Data Science Tutorial #2 - NumPy Arrays
NeuralNine
Python Data Science Tutorial #3 - Numpy Functions
NeuralNine
Python Data Science Tutorial #4 - Plotting Functions With Matplotlib
NeuralNine
Python Data Science Tutorial #5 - Subplots and Multiple Windows
NeuralNine
Python Data Science Tutorial #6 - Matplotlib Styling
NeuralNine
Python Data Science Tutorial #7 - Bar Charts with Matplotlib
NeuralNine
Python Data Science Tutorial #8 - Pie Charts with Matplotlib
NeuralNine
Python Data Science Tutorial #9 - Plotting Histograms with Matplotlib
NeuralNine
Python Data Science Tutorial #10 - Scatter Plots with Matplotlib
NeuralNine
Python Data Science Tutorial #11 - 3D Plotting with Matplotlib
NeuralNine
Python Data Science Tutorial #12 - Pandas Series
NeuralNine
Python Data Science Tutorial #13 - Pandas Data Frames
NeuralNine
Python Data Science Tutorial #14 - Pandas Statistics
NeuralNine
Python Data Science Tutorial #15 - Pandas Sorting and Functions
NeuralNine
Python Data Science Tutorial #16 - Pandas Merging Data Frames
NeuralNine
Python Data Science Tutorial #17 - Pandas Queries
NeuralNine
Python Machine Learning Tutorial #1 - What is Machine Learning?
NeuralNine
Python Machine Learning Tutorial #2 - Linear Regression
NeuralNine
Python Machine Learning Tutorial #3 - K-Nearest Neighbors Classification
NeuralNine
Python Machine Learning #4 - Support Vector Machines
NeuralNine
Python Machine Learning Tutorial #5 - Decision Trees and Random Forest Classification
NeuralNine
Python Machine Learning Tutorial #6 - K-Means Clustering
NeuralNine
Python Machine Learning Tutorial #7 - Neural Networks
NeuralNine
Python Machine Learning Tutorial #8 - Handwritten Digit Recognition with Tensorflow
NeuralNine
Generating Poetic Texts with Recurrent Neural Networks in Python
NeuralNine
Stock Portfolio Visualization with Matplotlib in Python
NeuralNine
Analyzing Coronavirus with Python (COVID-19)
NeuralNine
Making Text Images Readable Again with Python and OpenCV
NeuralNine
Neural Networks Simply Explained (Theory)
NeuralNine
Motion Filtering with OpenCV in Python
NeuralNine
Top 5 Programming Languages To Learn in 2020
NeuralNine
Simple TCP Chat Room in Python
NeuralNine
Image Classification with Neural Networks in Python
NeuralNine
Edge Detection with OpenCV in Python
NeuralNine
S&P 500 Web Scraping with Python
NeuralNine
Simple Sentiment Text Analysis in Python
NeuralNine
Introduction - Algorithms & Data Structures #1
NeuralNine
More on: AI Pair Programming
View skill →
🎓
Tutor Explanation
DeepCamp AI