5

My program runs perfectly when launched through terminal or the PythonLauncher. My program utilizes both a GUI written through pyside and a terminal console. When I wrap my program using py2app, running the produced .app file yields only the GUI, not the terminal shell. My program, therefore, does not work, because it is unable to call sub-processes in the terminal shell without the terminal shell being open.

Any ideas as to how I can have both the terminal shell and the GUI open? I assume this is an error with my setup.py or my py2app settings. Here's my setup.py

from setuptools import setup

APP = ['myProgram.py']
DATA_FILES = []
OPTIONS = {'argv_emulation': True}

setup(
    app=APP,
    data_files=DATA_FILES,
    options={'py2app': OPTIONS},
    setup_requires=['py2app'],
)

...and here's the terminal command I'm using to compile my application with py2app

python setup.py py2app

Thanks for the help, everyone!

Ian Zane
  • 2,209
  • 5
  • 23
  • 21
  • A terminal and GUI at the same time? It seems like an awful design to me! Can't you use a separate windows created from your GUI?Alternatively, why don't you simply open a new command prompt?(I'm not a windows user, but it shouldn't be hard...). – Bakuriu Jul 13 '13 at 17:19
  • I actually can't. I have to call into terminal with subprocess.call, so I'm relatively sure a terminal window *must* be open. Also, I'm on OS X, not Windows. Basically, my python app works when it isn't compiled into a .app, but when I compile it into one, it breaks because it won't open an instance of terminal to receive my subprocess.call commands. – Ian Zane Jul 13 '13 at 17:53
  • AFAIK `subprocess.call` doesn't have *anything* to do with the terminal. Please explain what you mean by "it breaks because it won't open an instance of terminal to receive my subprocess.call commands.". – Bakuriu Jul 14 '13 at 05:56

2 Answers2

3

Applications created by py2app are GUI application bundles and don't open a terminal window. If you really need a terminal window, instead of using a GUI window for input, you can launch the application from a terminal window ("MyApp.app/Contents/MacOS/MyApp" if your application is named MyApp).

BTW. I don't understand what you mean by "have to call the terminal by subprocess.call". Running command-line tools using subprocess works just fine in an application bundle, unless you need to interact with that process (for example because you are launching a TTY editor like vim or emacs).

Ronald Oussoren
  • 2,715
  • 20
  • 29
  • This does not seem to work for me. I don't get any output even when I run dist/MyApp.app/Contents/MacOS/MyApp – user239558 Feb 23 '15 at 23:23
0

When you build the setup.py using py2applet, you might try using the --emulate-shell-environment option:

python setup.py py2app --emulate-shell-environment

My application opens up a Terminal window when run if I build using that option.