The script I ran
# p2e_simple_con.py
# very simple script to make an executable file with py2exe
# put this script and your code script into the same folder
# run p2e_simple_con.py
# it will create a subfolder 'dist' where your exe file is in
# has the same name as the script_file with extension exe
# (the other subfolder 'build' can be deleted)
# note: with console code put a wait line at the end
from distutils.core import setup
import py2exe
import sys
sys.argv.append("py2exe")
sys.argv.append("-q")
# this is your code script file, change it as needed
# use it in the working directory or give full path
script_file = 'DateTime_Test1.py'
# create a single .exe file and use compression
# (the .exe file is 30% larger with no compression)
setup(
options = {'py2exe': {'bundle_files': 1, 'compressed': 1,}},
zipfile = None,
# replace console with windows for a GUI program
console = [{'script': script_file}]
)
I tried this but got the following error
C:\Python26\Lib\distutils\dist.py:266: UserWarning: Unknown distribution option: 'console'
warnings.warn(msg)
C:\Python26\Lib\distutils\dist.py:266: UserWarning: Unknown distribution option: 'zipfile'
warnings.warn(msg)
usage: py2exe.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: py2exe.py --help [cmd1 cmd2 ...]
or: py2exe.py --help-commands
or: py2exe.py cmd --help
error: invalid command 'py2exe'