Pyinstaller | Converting python scripts into executables

Reference: pyinstaller home

Question: How do you go from python -verbose to just myscrpt -verbose? Follow along to find out!

Before we begin

  1. Install the required packages

2. Add the python scripts folder to the system path if you have not done so already

The basics

  1. Basic usage

2. Useful options

  • — name | Specify the name of the generated executable
  • — onefile | Bundle all binary artifacts into one executable file
  • — distpath | Customize the output directory of the generated executable
  • -y or — no-confirm | Replace dist_path contents without asking for confirmation
  • — exclude-module | Ignore modules not required to make the executable
  • — paths | Specify additional import folders
  • — add-data | Include any additional data file e.g. config.xml
  • — add-binary | Include additional binary data files
  • More info.

3. Using the spec file to specify build options

  • As an alternative to specifying multiple command line options, you can use a spec file to generated your executable
  • Here is an example of a spec file you might use: