I need a program to compile python source code; as I found out at first I need to make a binary file from my python script.

I've already checked a lot of links, but still I haven't found something for Linux.

I found py2bin for OS/X, but there are no versions for Linux.

  • Python 2 or Python 3? Also, is Nuitka or dis closer to what you want? – Nathaniel M. Beaver Feb 20 '18 at 13:11
  • Cython is a popular optimizing static compiler for Python. – fpmurphy Feb 20 '18 at 13:15
  • wiki.python.org/moin/Freeze That method will compile executables for *nix systems. Although I'm not sure if that's what you want. – alpha Feb 20 '18 at 13:17
  • disassembling python code? – Rui F Ribeiro Feb 20 '18 at 13:22
  • Unless you mean create "precompiled" python modules (.pyc)? – xenoid Feb 20 '18 at 13:34

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.


  • 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.

  • 3
    pyinstaller doesn't compile python programs, it just pack so that the result package can be used like a binary package. So practically an extractor and execution of normal python. (it use pyc, so simple reverse engineering is difficult, but a tools that change identifier should also be used, if reverse engineering is to avoid). – Giacomo Catenazzi Feb 20 '18 at 14:46
  • @GiacomoCatenazzi Thanks, I already suspected that. I also suspect it to be the case of py2bin, you can place scripts/python/perl programs under a "binary" package in MacOS. – Rui F Ribeiro Feb 20 '18 at 14:49
  • 1
    I doesn't know. On older time, there where a python to C (+compiler) (py2bin is so old, so maybe...). Cython could be a solution, but I doesn't know if and how the code should be modified (so it will be no more pure Python). – Giacomo Catenazzi Feb 20 '18 at 14:57
  • @GiacomoCatenazzi Thanks for your insights. – Rui F Ribeiro Feb 20 '18 at 15:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.