Convert any .py to .exe with python

Search for a command to run...

Wystarczy zdecydować się na zakup obserwujących na insta !
Hi Ayushi! Thanks for sharing the knowledge. It was new learning . Just wanted to check on that I am using Anaconda software for python and for coding Jupyter or Spyder notebook. Do I really need to install separate Python latest version. Thanks again!!
Does .exe file contains all the external library and dependency which are imported in the python code?
Yes, it will be having all the external libraries and dependencies that you are having in your file. Feel free to having any external libraries in your file and convert the same to executable file. I don't use -pip and also don't convert any file to .exe because it closes too fast ⏩ and it's better to having the same in my complier. However, you can try it out 🙄
The series content will mostly cover Technical Python tutorials and my recent learnings and experience in Python.
A curated list of Ultimate Python resources is here! (If you are getting started with #Python or a senior Python developer, you wouldn't wanna miss this) 😄 A lot of people have been recently asking me about python books, courses to refer and other r...
All you need to know about Hacktoberfest 2021

Hello reader! Well, Hacktoberfest is something, you are gonna hear a lot about in the coming month. You can refer to my YouTube video Tutorial to see a working tutorial for better understanding and a step-by-step guide of the same. https://www.yo...

Hello reader! In this Blog post, I will share some useful code snippets and functions in Python. Give it a read. Let's get started! 1. Memory The method getsizeof can be used to retrieve the size of any object. Here's an example of the same. import...

Hello reader! Whenever a client sends a request to the server, the response always contains a status code. You might not see it always but it's returned at every client-server interaction. Well, even if you are not a programmer, you would still know...

Hello reader! Microsoft subsidiary GitHub launched Copilot to power pair programming with AI. In this blog post, I will share all you need to know about it. You can refer to my YouTube video Tutorial to see a working tutorial for better understandin...

When you create a python program and you want to share it with the world and you want them to run your script without having to install python. You can do this by converting the .py file to .exe file. In this article, I will show you how you can do it.
You can refer to the YouTube video Tutorial for better Understanding!
Repository for Ultimate Resource in python. Drop a star if you find it useful! Got anything to add? Open a PR on the same!
I recently created a digital clock with python using Tkinter. I am going to use the same program to demonstrate the conversion of .py file to .exe file.
- What is an executable file?
- Types of executable file formats
- how to convert .py file to .exe file
In computing, executable code, executable file, or executable program, sometimes simply referred to as an executable or binary, causes a computer " to perform indicated tasks according to encoded instructions".
Unlike a data file, an executable file cannot be read because it's compiled.
A file with an executable file extension means that the file format supports some ability to run an automatic task.
If you wish to know more about it, You can use this link to navigate to its Wikipedia Page
Note: Please exercise caution before opening any executable file, especially those received in suspicious emails or downloaded from unfamiliar websites. So, let's get started!
Use this link to navigate to list of executable file formats at Wikipedia Page
It's Time to code! You can find all the code at my GitHub Repository.
Open the folder where you will find the python script which you will convert to .exe file
Press Shift and hit Right-click

Select Open power shell window here
Next, run the following command in your terminal.
pip install pyinstaller
PyInstaller bundles a Python application and all its dependencies into a single package. The user can run the packaged app without installing a Python interpreter or any modules. PyInstaller supports Python 3.5 or newer.
PyInstaller is tested against Windows, Mac OS X, and GNU/Linux. If you wish to know more about it, Use this link to navigate to its documentation. Once the necessary package is installed, let's move forward!
pyinstaller -w -F -i "C:\Users\imar\OneDrive\Desktop\YouTube Tutorial/pytoexe/icon.ico" clock.py
Let's Understand this now.
Once the command runs successfully, the executable file will get created inside dist folder.
-w : When you run the executable file, a terminal window will get opened at the back while the executable runs. To prevent this from happening. you can use -w flag.
-F : When you convert your .py file to .exe file, it comes with a lot of other dependencies. The dependency files will be created along with the .exe file inside the dist folder. So this flag gives you the power to bind all the dependencies into a single file instead of multiple ones.
This comes in handy as if you wish you wish to share your program file to someone you would want to give them a single file rather than sharing a folder containing the .exe file along with a bunch of other dependency files.
.exe file. Note: The icon must be in .ico format only. You can use this link to navigate to a website that does this job for you or you can use any other website of your choice to perform this task.
Finally hit enter and run the command. A new dist folder will be created which contains your executable file. Note that now no terminal window opened at the back, no separate dependency file is generated and you have your icon for the application.
That's it. we are done! Simple isn't it?
You can find all the code at my GitHub Repository.
If you have any queries or suggestions, feel free to reach out to me.
You can connect with me on Twitter.
You should definitely check out my other Blogs:
Resources:
See you in my next article, Take care!