Convert script to .exe python

1

Well folks the fact is that I'm starting in this programming by learning python. And I've searched for information about how to make your sript executable on a computer where the interpetre is not installed. I have already read that for that the file is converted to an .exe but I am not entirely clear as is the process. Could you tell me what library is used for this or how is the process? And make it executable in both win, mac and linux. What I want to convert is a console application. and I use python 3.

    
asked by limg21 28.05.2017 в 20:58
source

1 answer

1

Your query points to what is known as "freeze" or frozen applications, is basically a way to distribute your program along with the dependencies plus a python interpreter with all its dependencies. This process usually creates a folder, a zip or even an exe, in theory with everything your application needs to run completely independently and "portable". This process is never multiplatform, that is: to make a distribution for Linux, you need a Linux + Python + freeze tool that runs under this OS, as with the rest of the operating systems. In short, the traditional methods of distribution through the source code are usually much more comfortable in this regard, however both Win with Mac are SOs where we can not assume that we have python installed, in Linux I would say that almost certainly all the distros have the interpreter, but surely not all with the latest versions.

What options for distribution do we have?

Cx_freeze : Allows execution in all three OSs and therefore arming the corresponding distributions. You can generate a folder with an executable and all the dependencies. Supports from version 2.7 of the interpreter onwards.

pyinstaller : Like the previous one, it runs in the main OSs. Under Windows you have the possibility to create a single EXE with all the scripts, dependencies and interpret inside it, and then automatically decompress everything in a temporary folder and run transparently. It is compatible with versions 2.7 and 3.3-3.5 of the interpreter.

py2exe : It has been a little behind with respect to the previous tools since I only point to the Windows environments.

In general, all these tools have a simple or advanced way of working. In the first case, for example with pyinstaller , you could simply do (under win) pyinstaller miapp.py --onefile and you would get a miapp.exe with everything included. This simple mode obviously works with simple requirements and simple scripts, for more advanced things you have to configure everything using a script, in the case of Cx_freeze , use the typical setup.py that uses the distutils, in the other case, you have to create a file of specifications but in both cases they are still scripts of python , through these files we can configure things like, the inclusion of icons, graphics, data files, unrecognized dependencies, or simply define the icon of our program.

    
answered by 29.05.2017 / 01:00
source