Some newbie questions the FAQs didn't answer!

Robin Munn rmunn at pobox.com
Wed Apr 2 19:36:01 EST 2003


Verlee <verlee at web.de> wrote:
> Hi,
> 
>> [...] But then I read that in order to run a python program, the
>> machine had to have the python VM installed, and > the user had to go
>> to a command line and type "python <program name>>.py".
> 
>> What I had planned to do was write Win32 GUIs, but I would guess that
>> most common users don't have Python installed.  Is there some way to
>> write the program in C++ and then have it bring up the GUI written in
>> Python without Python being installed?  Wouldn't that require the code
>> being compiled into machine code?

A better way would be to write the whole thing in Python and then use a
tool like py2exe to bundle up the Python interpreter with your code in a
single .EXE file. (See below.)

> There is a tool called py2exe that converts .py-files to .exe-files
> which can be executed without having the Python interpreter installed.
> I figure this is what you want to have?
> (I´ve been worrying a lot about this, too...)
> It can be downloaded at http://sourceforge.net/projects/py2exe/
> Haven´t had time to try it yet, though. There may also be other tools
> that do the same, but this is the (only) one I have heard of.

I've done this; not with any large application, but with a small
wxPython test program that brought up a GUI window. It produced a single
.EXE, which I was able to copy to a machine that didn't have Python
installed, and it worked perfectly.

BTW, if you're planning on writing GUIs in Python, I would recommend
staying *far away* from the Windows API, and using one of the
cross-platform Python GUI toolkits instead. I once spent three months
trying to write something in the Windows API -- it was *painful*. Using
one of the cross-platform toolkits, on the other hand, will not only be
*much* more pleasant, it will also allow you to produce programs that
can run on Unix, Windows, and Macintosh systems, all with no extra
effort on your part! There are several toolkits available, but I'm
partial to wxPython myself: I've found it quite easy to understand and
use, and (unlike some other toolkits) it looks native on each platform.
That is, on Windows it looks just like a normal Windows app; on
Macintosh it looks just like a normal OS X app (or OS 9 if that's what
the user is running); and on Unix it looks just like a normal GTK app.

Anyway, just some food for thought.

-- 
Robin Munn <rmunn at pobox.com>
http://www.rmunn.com/
PGP key ID: 0x6AFB6838    50FF 2478 CFFB 081A 8338  54F7 845D ACFD 6AFB 6838




More information about the Python-list mailing list