PyInstaller

PyInstaller is a program that freezes (packages) Python programs into stand-alone executables, under Windows, Linux, Mac OS X, FreeBSD, Solaris and AIX.

Its main advantages over similar tools are that PyInstaller works with Python 2.7 and 3.4—3.7, it builds smaller executables thanks to transparent compression, it is fully multi-platform, and use the OS support to load the dynamic libraries, thus ensuring full compatibility.

1.install

1
pip3 install pyinstaller

2.Go to your program’s directory and run

1
pyinstaller myscript.py

This will generate the bundle in a subdirectory called dist.
PyInstaller analyzes myscript.py and:

  • Writes myscript.spec in the same folder as the script.
  • Creates a folder build in the same folder as the script if it does not exist.
  • Writes some log files and working files in the build folder.
  • Creates a folder dist in the same folder as the script if it does not exist.
  • Writes the myscript executable folder in the dist folder.

In the dist folder you find the bundled app you distribute to your users.

What to generate:

1
2
3
4
5
6
7
8
-D 
Create a one-folder bundle containing an executable (default)

-F
Create a one-file bundled executable.

-n NAME
Name to assign to the bundled app and spec file (default: first script’s basename)

more info:
pyinstaller manual