[Tutor] Using py2exe

Hans Dushanthakumar Hans.Dushanthakumar at navman.com
Wed Nov 23 00:04:29 CET 2005

   Im trying to convert a python program to a stand-alone executable
that I can distribute. How do I use py2exe to do this?
   The python program consists of a py script that uses (imports)
several other modules (py scripts) located in another directory.

Heres what Ive tried so far:

   1) Running "python setup.py py2exe" on the cmd line created the
required exe file. Hoever, on running the exe file, it reports an error:
  File "log_all_msgs_spartacus.py", line 8, in ?
ImportError: No module named listener

   2) Running the command followed by comma seperated module names (all
modules that are imported by the main script)

python setup.py py2exe -i ..\lib\listener.py, ..\lib\
sender.py, ..\lib\gpsmsg.py, ..\lib\envmsg.py, ..\lib\cmds.py,
..\lib\logger.py, ..\lib\nmea.py

Produced the foll error:
invalid command name '..\lib\sender.py,'

The contents of setup.py is as follows (got it off the py2exe website):

from distutils.core import setup
import py2exe

    version = "0.0.1",
    description = "Log_all_msgs_from_Spartacus",
    name = "Spartacus_monitor",

    # targets to build
    console = ["log_all_msgs_spartacus.py"],

Once I've created the exe file, can it be run on a PC which does not
python setup in it? Note: - the program uses the standard pyserial
module as well.


More information about the Tutor mailing list