How to Convert Python Scripts To Binary Files (.exe)

In this post, we will see how we can convert python scripts to binary files. In a more pythonic way how to convert .py file to .exe file.

But first, lets understand why there is a need of binary files.

Automate Boring Stuff With Python

How To Convert Python Files To Binary Files
How To Convert Python Files To Binary Files

Merits of Binary Files

The binary file can be executed in any system without installing the actual scripting language or any module. A developer can convert scripts to binary files and give it to the client. A client can use the binary file to run the script.

One thing to note that you have to run the binary file in 64 bit operating system only if you have used a 64 bit operating system to convert .py file to .exe file.

Check out our entire posts on python scripting for storage admins.

Convert a Python Scripts To Binary Files

We will use a python module called pyinstaller to convert a .py file to .exe file. Py

Step 1. Open Command Prompt

Step 2. Install pyinstaller module by executing below command

pip install pyinstaller

Step 2. Traverse to the directory where the python file is located.

Step 3. Convert Python Files to Binary Files

pyinstaller info_collector.py –onefile

The above command will bundle all dependencies and convert python scripts to binary files. The location of the .exe file will be displayed at the bottom.

Just copy that .exe file and run it.

If you still need more information, then check out the below YouTube video. It explains a step by step guide to convert a .py file to .exe file.

Subscribe to our newsletter and YouTube Channel for more such posts.

Leave a Comment