DEV Community

Cover image for Converting .py to .exe
Anjali Jha
Anjali Jha

Posted on

3

Converting .py to .exe

To share your Python projects with the world it needs to be converted from .py to .exe file, exe file is an executable file format. It contains a program and has the ability to run as a program in computer. It does not require any import statements to execute.

Let's get started

Step 1:

Install the library pyinstaller. You can do so by typing the following code into your command prompt.

pip install pyinstaller
Enter fullscreen mode Exit fullscreen mode

Step 2:

Go to the folder where .py file is located. You’ll see few folder created newly. Now Press the shift button and simultaneously right-click to open PowerShell window.

Step 3:

Type the following command:

pyinstaller --onefile 'filename.py' 
Enter fullscreen mode Exit fullscreen mode

It will take some time to finish the process depending on the size of your project. You will get a "Building EXE completed successfully" message.

Step 4:

Open your dist folder, here you will find your .exe file and you are good to go!!!

Done phewww

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (4)

Collapse
 
pranavbaburaj profile image
Pranav Baburaj

You can also use auto-py-to-exe . auto-py-to-exe works based on pyinstaller. Its just a GUI

Collapse
 
anjalijha22 profile image
Anjali Jha

Wow! Good to know that.

Collapse
 
aatmaj profile image
Aatmaj

Good!

Collapse
 
anjalijha22 profile image
Anjali Jha

Thanks!!!

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay