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?

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

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

Step 1:Install the Pyinstaller Package

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

pip install pyinstaller

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 :


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:

pyinstaller --onefile

In My case file name is

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: