Converting .py File To .exe File

Here we are going to learn, how to convert a .py (Python file) into a .exe file.

What are .exe files?

A .exe file is a common filename extension denoting an executable file ( the main execution point of the computer programming) for the Microsoft window.

In simple words, we create lots of programs per day and want to share them with the world but not everyone has an environment with a compiler and interpreter to run our code. But everyone has an operating system and in windows .exe file executes the program.

(For more information on Convert Python file to .exe file, kindly refer to this documentation https://www.geeksforgeeks.org/convert-python-script-to-exe-file/)

Let's Convert Random Password Generator GUI into an executable file.

(for understanding how we build random password generator using GUI read our previous blog:

https://medium.com/nerd-for-tech/random-password-generator-using-tkinter-635f61cfaae8 )

Step 1:Install the Pyinstaller Package

In the cmd, type the following command to install the pyinstaller package .

Step2: Save your Python Script

Now you’ll need to save your Python script at your desired location.

I have saved my random password generator script in :

C:\python

Step3:Create the Executable using Pyinstaller

Now you’ll be able to create the executable from the Python script using pyinstaller. Simply go to the Command Prompt, and then go to your file location using cd command.

Next, use the following code to create the executable file in command prompt:

In My case file name is random_password_generator.py:

Done!!!!. Your executable file is created it's that simple.

Step 4: Run the Executable

Your executable should now get created at the location that you specified. Under the folder name dist.

Once you click on the file, you should be able to launch your program and now it is an application so it will run on any device.

Download the project from:

https://github.com/Platforuma/medium_blog/tree/main/random%20password%20generator