3

I finally got py2app to work, and my program was made. However, it won't open because it relies on the terminal and raw_input. I just found out py2app is more for GUI interfaces.

All I want, is to turn the program into an application my users can click on, and it'll open in Terminal. Without them having to either install Python, or go to the terminal and type python "filename" (also, don't they have to set up the paths and everything to do that?).

Please help; I've been pulling my hair out all day looking for the answer. If this isn't possible, I'm just going to give them the .py file and instruct them to start it with python in the terminal and hope it's already set up so they can do that.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
user1159454
  • 3,267
  • 3
  • 19
  • 25
  • Investigate the `open` command (`man 1 open`). Using `open -n /Applications/Utilities/Terminal.app` launches a new Terminal. I've not yet worked out how to specify the command to be run. Python is installed in `/usr/bin` so that should be available without any extra setup. – Jonathan Leffler Aug 04 '13 at 04:29
  • Ok, thanks but wouldn't they still have to go into Terminal to type the "open" command? – user1159454 Aug 04 '13 at 04:35
  • You should be able to create something that is clickable that launches the terminal — maybe using `open` or maybe via another mechanism. I've been too damn lazy to work out how to do it. – Jonathan Leffler Aug 04 '13 at 04:57
  • You may find [Programmatically launch Terminal.app with a specified command (and custom colors)](http://stackoverflow.com/questions/4404242/programmatically-launch-terminal-app-with-a-specified-command-and-custom-colors) useful. Ditto [Opening a new terminal from the command line and running a command on Mac OS X?](http://superuser.com/questions/174576/opening-a-new-terminal-from-the-command-line-and-running-a-command-on-mac-os-x) – Jonathan Leffler Aug 04 '13 at 05:18

2 Answers2

1

I know that on a mac you change the extension of the file to .command and that will make it so you can just click on it and it will run through the terminal if that's what it is specified to do. However I'm not sure if it will work if they do not actually have python installed.

Argiri Kotsaris
  • 492
  • 3
  • 7
  • Hi, thanks for the answer. I tried that, but now it's giving me some error message upon opening it about permissions. I checked the permissions and everyone is allowed to read & write so I don't know – user1159454 Aug 04 '13 at 04:29
  • Yea that's the unfortunate downside to that method is you'd have to run a `chmod 777 /path/to/file` so that everyone can execute as well... I haven't found a much better method than that though yet.. – Argiri Kotsaris Aug 04 '13 at 04:35
  • Hmm, I did the chmod and it opened, but broke because it couldn't import things (it has a few imports). Alright, forget it, I'll just release the whole script for them. Thanks! – user1159454 Aug 04 '13 at 05:00
  • @user: Just to let you know, it should be possible to get this to work with reasonable imports. Including the imports is a primary function of both py2app and pyinstaller. – tom10 Aug 04 '13 at 18:58
0

Using PyInstaller http://www.pyinstaller.org/ it's possible to make an executable for different platforms. I believe OSX is supported.

Kalail
  • 155
  • 7