Skip to content
How to create an executable file from a Python script?
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
assets video added Feb 10, 2019
speed_test test results Feb 10, 2019
LICENSE Initial commit Feb 9, 2019
Pipfile initial commit Feb 9, 2019
Pipfile.lock requests updated May 7, 2019 related work Mar 19, 2019 initial commit Feb 9, 2019 I/O operations (read/write file) Feb 10, 2019 initial commit Feb 9, 2019
input.txt I/O operations (read/write file) Feb 10, 2019

Python EXE

A simple project that demonstrates how to create an executable from a Python project.

Here, is the main file. It uses a module (, it imports the os module from the stdlib, and it even uses a 3rd-party library (requests).

With PyInstaller, you can easily create a single executable from this project.

$ pyinstaller --onefile

Under Windows you might have a problem with this. If the .exe complains that a DLL is missing, then try this variation:

$ pyinstaller --onefile --noupx

You'll find the exe in the dist/ folder.

Why would you need an EXE?

It makes distributing your program much easier. The exe produced by PyInstaller is standalone. It's enough to give this exe to your friend and (s)he can run it right away. There is no need to install Python on his/her machine, create a virtual environment, etc.

Of course, if your friend uses Windows (Linux), then create the exe under Windows (Linux).

Will my EXE run faster?

No. PyInstaller simply creates a bundle that contains everything: your code, the necessary modules / packages, the virtual environment, the Python interpreter, etc. When you launch the EXE, it is extracted to your temp folder (under Linux it's the /tmp folder), and your application is started from there. So the runtime will be approximately the same.

For a demo, check out my simple Fibonacci implementation in the folder speed_test.


pynt is a minimalistic build tool. If you installed everything with pipenv (pipenv install --dev), then you can also create the executable with the following commands:

$ pynt exe

or (using pyinstaller's --noupx switch)

$ pynt exe2


Click on the image below to open a YouTube video that shows you everything step-by-step:

view demo on YouTube

Links / News / Related Work

You can’t perform that action at this time.