[Tutor] Creating a single .exe file without py2exe and pyinstaller

Marc Tompkins marc.tompkins at gmail.com
Sun Oct 19 18:03:47 CEST 2008

On Sun, Oct 19, 2008 at 7:51 AM, Robert Berman <bermanrl at embarqmail.com>wrote:

>  If you want a real exe rewrite it in C or C++. Python is an interpretive
> language; my apologies to those who say it is 'semi-compilable'.

Let me re-word that a little bit.
When you write an application in Python, you are actually writing a "script"
that will be "interpreted" by Python at run-time (Python _must_ be installed
and running) - so Python is called a "scripting" or "interpreted" language.
This is different from writing it in a "compiled" language like C, C++, etc.
There are advantages and disadvantages to both approaches; Pythonistas tend
to find that the advantages of the Python way outweigh the disadvantages.

When you write a program in anything higher-level than machine code, you're
borrowing from millions and millions of man-hours of programming expertise.
I have no idea what your 40-45 line script does, but even in "Hello World"
there's a lot going on that you aren't aware of unless you're writing
machine code (even assembly language masks _some_ of the complexity):
-  Memory allocation
-  String manipulation
-  I/O
and a bunch of stuff I'm forgetting.  This stuff doesn't just happen -
computers don't automatically understand _anything_ - they have to be taught
very explicitly, and that requires a lot of code.  If you were writing in C
(for example), that code would be in the form of libraries which would
either be linked into your EXE (making it much bigger than you'd expect it
to be), or would have to be distributed alongside as DLLs.  In Python, it's
modules and the Python interpreter.  In either case, when you write even the
simplest program, it requires lots and lots of other people's code to run.

When you distribute your script to users, they can't run it unless they have
Python on their machines.  Pyinstaller gathers up your script and all of its
dependencies and makes an installable package out of them; Py2EXE bundles
that up with a minimal distribution of Python so your user only has to run
one installer.  That's what all of those "unnecessary files" are.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20081019/66fbf666/attachment.htm>

More information about the Tutor mailing list