Compiling Python Code to Executable with nuitka – Ohidur's Blog

submited by
Style Pass
2022-08-14 07:30:02

Nuitka is the Python compiler. It is written in Python. It is a seamless replacement or extension to the Python interpreter and compiles every construct that CPython 2.6, 2.7, 3.3, 3.4, 3.5, 3.6, 3.7, and 3.8 have, when itself run with that Python version.

In case you have a plugin directory, i.e. one which cannot be found by recursing after normal import statements via the PYTHONPATH (which would be the recommended way), you can always require that a given directory shall also be included in the executable:

If you don’t do any dynamic imports, simply setting your PYTHONPATH at compilation time will be sufficient for all your needs normally.

Use --include-plugin-directory only if you make __import__() calls that Nuitka cannot predict, because they e.g. depend on command line parameters. Nuitka also warns about these, and point to the option.

If you want to be able to copy it to another machine, use --standalone and copy the created program.dist directory and execute the program.exe (Windows) or program (other platforms) put inside.

Leave a Comment