+ 4
Python is an interpret language but if it is true does it mean that we have to distribute source code while distributing program
4 Réponses
+ 6
You can "compile" it to an executable, but this single file will still contain the whole interpreter and all imported modules.
You might end up with a 45MB file just printing "Hello world" :)
+ 7
There are a few ways to make a .py script .exe-cutable. py2exe, cx_freeze or nuitka modules come to my mind.
However, as Python is an interpreted, not a compiled language, those modules pack everything into the executable - including the interpreter itself, all the needed modules, external files (textures, media, etc). This is then called 'a build'.
So your output file (or folder, if you're going easy and allow those builds to be folders with all those files you imported and just include one executable to run) might get very heavy, quickly. The interpreter alone may weight some 30-40MB, although there are ways to get it a bit lower.
The big advantage of such a solution is that it will run everywhere-ish* even when there is no Python installed on the machine. But it will not be too efficient, as it will have to unpack everything into RAM each time it is executed.
There is no right or wrong here, you just need to know how it works and accept that.
* - it gets tricky when you have a 64-bit Python and compile a file you want to later run on a 32-bit version - it won't go. Pls make sure you make your build in the lowest possible settings or be prepared to produce several "compilation" versions. That will maximize the chance for your project to run everywhere.
+ 3
no. there are various ways to create an executable out of a .py file.
+ 2
@Kuba sir, I didn't get what you said. A simple illustration would be helpful :)