How to compile Python Code using Pyinstaller for Complete Beginners? – Windows Edition (2021)

Just finished your Python program and need to make it into an actual executable Program. Well, we will learn how to compile Python code in this read.

What exactly is Pyinstaller?

Pyinstaller is a tool that takes away the hassle when it comes to compiling your program into an executable program (.exe). Pyinstaller takes all the files and data required to produce a functioning program and bundles them together to produce one solid application.

How do I install Pyinstaller? (Windows Edition)

When it comes to installation the process is rather seamless.

Installation of Pyinstaller through Command Prompt (CMD)

In order to install through command Prompt, we are going to make use of a basic command. Follow my drift.

In command prompt enter pip install pyinstaller

This will fetch the Pyinstaller library and install it on your machine.

Now that we have Pyinstaller on our machine let’s learn how to use it in order to compile the Program.

In order to compile the Python Program, we are going to follow a few short steps.

What will you need?

The absolute path of where the code is located. I recommend you have an isolated folder with just the files pertaining to the program.

Ensure that your python scripts have no spaces in the name example This will help to eliminate possible issues.

Steps to Compile Python Program

Open Command Prompt

Enter the following template to initiate the new path you have obtained of the folder in which your code belongs.

cd the\path\of\your\program\is\located

cd – allows for your path to be defined.

Enter the Compilation Command

pyinstaller –onefile -w (press enter after)

-w Allows for only the application window to show instead of being accompanied by the CMD Console.

–onefile serves to bundle the majority of the components in the executable file reducing the number of folders and other files.

Await Completion

After the series of processes are done, you should visit the location of your code and enter into the dist folder. You should see an executable file.

Final Remarks

This is a basic way of compiling your program, I wish to advise that your program can be decompiled and your logic exposed. In further publications, I will explain how you can secure your code.

Helpful Resources



  1. My relatives ɑll the time say that I am killing my time here at web, however Ι know I
    am getting experience еvery day by reading suⅽh fastiɗioսs articleѕ.

  2. Youг way of explaining the whole thing in this piece of writing is genuinely fastidious, every one be caрabⅼe of
    without difficultу be awaгe ߋf it, Thanks a lot.

Leave a Comment