How can I get a binary from a .py file

In my opinion your problem in Google stems for calling a compiler capable of producing binaries from python a "disassembler".

I have not found a true compiler, however I have found in Google a python compiler packager, which packs all the necessary files in a directory, obfuscating them, with an executable frontend: pyinstaller at http://www.pyinstaller.org/ ; it appears to be actively supported, as the last version 3.4 which was released on 2018-09-09, contrary to py2bin which seems to be not actively maintained.

Features:

  • Packaging of Python programs into standard executables, that work on computers without Python installed.
  • Multi-platform, works under:
    Windows (32-bit and 64-bit),
    Linux (32-bit and 64-bit),
    Mac OS X (32-bit and 64-bit),
    contributed suppport for FreeBSD, Solaris, HPUX, and AIX.
  • Multi-version:
    supports Python 2.7 and Python 3.3—3.6.

To install:

pip install pyinstaller

Then, go to your program’s directory and run:

pyinstaller yourprogram.py

This will generate the bundle in a subdirectory called dist.


Try Nuitka. It takes a .py and then creates a .bin. It works on Gnu+Linux and is in most popular distribution's software repositories.

Nuitka is a Python compiler written in Python.

It's fully compatible with Python 2.6, 2.7, 3.3, 3.4, 3.5, 3.6, and 3.7.

You feed it your Python app, it does a lot of clever things, and spits out an executable or extension module.

Free license (Apache).

https://nuitka.net/pages/overview.html