Compilar python

He buscado la manera de compilar el código python y convertirlo en binario, ya que me he encontrado casos en que un usuario no es administrador de su máquina o no puede obtener los módulos y librerías
necesarios de sus repositorios.
En GNU/Linux la única forma que medianamente me ha funcionado es cx_freezer
donde para debian testing no está en los repositorios y he tenido que compilarlo.

En principio funcionaba bien salvo a la hora de usar matplotlib, no importa el modulo de tkagg ni el de gtkagg ni el de qt4agg para poder visualizar directamente una gráfica.
Poniendo agg funcionaba pero solo podía grabar la salida en ficheros no visualizarlos.

¿se os ocurre algún compilador mejor?

3 comentarios:

  1. General Programming FAQ - 1.3 How can I create a stand-alone binary from a Python script?

    You don't need the ability to compile Python to C code if all you want is a stand-alone program that users can download and run without having to install the Python distribution first. There are a number of tools that determine the set of modules required by a program and bind these modules together with a Python binary to produce a single executable.

    One is to use the freeze tool, which is included in the Python source tree as Tools/freeze. It converts Python byte code to C arrays; a C compiler you can embed all your modules into a new program, which is then linked with the standard Python modules.

    It works by scanning your source recursively for import statements (in both forms) and looking for the modules in the standard Python path as well as in the source directory (for built-in modules). It then turns the bytecode for modules written in Python into C code (array initializers that can be turned into code objects using the marshal module) and creates a custom-made config file that only contains those built-in modules which are actually used in the program. It then compiles the generated C code and links it with the rest of the Python interpreter to form a self-contained binary which acts exactly like your script.

    Obviously, freeze requires a C compiler. There are several other utilities which don't. One is Thomas Heller's py2exe (Windows only) at


    Another is Christian Tismer's SQFREEZE which appends the byte code to a specially-prepared Python interpreter that can find the byte code in the executable.

    Other tools include Fredrik Lundh's Squeeze and Anthony Tuininga's cx_Freeze.

  2. Hass, esas las estuve probando, la única que conseguí que funcionase medianamente bien fue la de cx_freeze.