8

this is my very simple code, printing argvs:

import sys

argv=sys.argv
for each in sys.argv:
    print each

here's the output when ran:

e:\python>python test1.py 1 2 3 4 5
test1.py
1
2
3
4
5

I want it to be compiled, so I made one with py2exe:

e:\python>python setup.py py2exe

and my setup.py:

from distutils.core import setup
import py2exe, sys, os

sys.argv.append('py2exe')

setup(
    options = {'py2exe': {'bundle_files': 3}},
    windows = [{'script': "test1.py"}],
    zipfile = None,
)

and I don't get any output when I run my program by test1.exe 1 2 3 4 5 or with any other argvs. sys.argvs should be a list with at least one object(test1.exe) in it, therefore I think I have misunderstandings with print function of python. Is there anything I'm doing wrong here? I just want everything to be printed to commandline. I program from linux, but windows users should be using my program.

thank you very much

thkang
  • 11,215
  • 14
  • 67
  • 83

1 Answers1

10
# ...
windows = [{'script': "test1.py"}],
#...

windows option is used to create GUI executables, which suppresses console output. Use console instead:

from distutils.core import setup
import py2exe, sys, os

sys.argv.append('py2exe')

setup(
    options = {'py2exe': {'bundle_files': 3}},
    console = [{'script': "test1.py"}],
    zipfile = None,
)
Avaris
  • 35,883
  • 7
  • 81
  • 72