Be a Supporter!

Python to Mac .app

  • 343 Views
  • 11 Replies
New Topic Respond to this Topic
MrMojoRisin5
MrMojoRisin5
  • Member since: Jun. 21, 2011
  • Offline.
Forum Stats
Member
Level 12
Programmer
Python to Mac .app 2013-06-23 08:08:01 Reply

So I'm trying to convert my Python script (which uses the console only) to a Mac OS X .app file (an application, basically). I have tried both py2app and Platypus. py2app created an .app that throws an error when I run it. Platypus also created an .app, but whenever I run it I get an error...I googled and from the little information I found, there is a chance that Python scripts converted to .app with Platypus do not involve interactivity. Any ideas on how I can make my Python script into a Mac executable (.app)?


-Got to keep on risin'...
-Check out FlashFrame
-Check out my YouTube channel and my blog

BBS Signature
Diki
Diki
  • Member since: Jan. 31, 2004
  • Online!
Forum Stats
Moderator
Level 13
Programmer
Response to Python to Mac .app 2013-06-23 13:11:58 Reply

What errors are the py2app and Platypus made app files giving you?

MrMojoRisin5
MrMojoRisin5
  • Member since: Jun. 21, 2011
  • Offline.
Forum Stats
Member
Level 12
Programmer
Response to Python to Mac .app 2013-06-23 19:11:05 Reply

At 6/23/13 01:11 PM, Diki wrote: What errors are the py2app and Platypus made app files giving you?

They both say "EOFError: EOF when reading a line"

You know my code, it's basically a raw_input inside a theoretically infinite while loop.


-Got to keep on risin'...
-Check out FlashFrame
-Check out my YouTube channel and my blog

BBS Signature
Diki
Diki
  • Member since: Jan. 31, 2004
  • Online!
Forum Stats
Moderator
Level 13
Programmer
Response to Python to Mac .app 2013-06-23 20:53:52 Reply

That's probably because you wrote the code in Windows which uses \r\n for its line endings whereas OSX uses just \r. Try converting your line endings to OSX and give it another shot.

If it's not that then you must have somehow mixed spaces and tabs for your whitespace in the process of moving the files over. I'd take a look for that as well.

Thegluestickman
Thegluestickman
  • Member since: Mar. 16, 2007
  • Offline.
Forum Stats
Member
Level 13
Game Developer
Response to Python to Mac .app 2013-06-23 23:24:12 Reply

At 6/23/13 08:53 PM, Diki wrote: If it's not that then you must have somehow mixed spaces and tabs for your whitespace in the process of moving the files over. I'd take a look for that as well.

Wouldn't that just throw a TabError instead?


To protect the world from devastation.
kidd25 is the best Newgrounder ever.

BBS Signature
Diki
Diki
  • Member since: Jan. 31, 2004
  • Online!
Forum Stats
Moderator
Level 13
Programmer
Response to Python to Mac .app 2013-06-23 23:50:05 Reply

At 6/23/13 11:24 PM, Thegluestickman wrote: Wouldn't that just throw a TabError instead?

Oh derp, you're right. Forget I said that part. :)

MrMojoRisin5
MrMojoRisin5
  • Member since: Jun. 21, 2011
  • Offline.
Forum Stats
Member
Level 12
Programmer
Response to Python to Mac .app 2013-06-24 07:16:13 Reply

At 6/23/13 08:53 PM, Diki wrote: That's probably because you wrote the code in Windows which uses \r\n for its line endings whereas OSX uses just \r. Try converting your line endings to OSX and give it another shot.

Yeah, I'm more of a total noob when it comes to this. How do I convert the line endings?


-Got to keep on risin'...
-Check out FlashFrame
-Check out my YouTube channel and my blog

BBS Signature
MrMojoRisin5
MrMojoRisin5
  • Member since: Jun. 21, 2011
  • Offline.
Forum Stats
Member
Level 12
Programmer
Response to Python to Mac .app 2013-06-24 10:22:54 Reply

Yeah, nevermind, I did a find and replace with TextWrangler. It still doesn't work, though, it just throws the same error.


-Got to keep on risin'...
-Check out FlashFrame
-Check out my YouTube channel and my blog

BBS Signature
Diki
Diki
  • Member since: Jan. 31, 2004
  • Online!
Forum Stats
Moderator
Level 13
Programmer
Response to Python to Mac .app 2013-06-24 11:54:08 Reply

I did some reading and the problem is because when the app file is made it is intended to be a GUI application so there is no terminal tied to it, so it has no way of receiving standard input, so you get that error. The only way to make it work with py2app would be to make your own GUI. There is a StackOverflow question similar to this here if you want to read up on it a little bit.

At 6/24/13 07:16 AM, MrMojoRisin5 wrote: Yeah, I'm more of a total noob when it comes to this. How do I convert the line endings?

If you use Notepad++ you can convert them with Edit > EOL Conversion.
If you use Sublime Text (which is the editor I use and highly recommend) you can convert them with View > Line Endings.

Can't say how to do it in other text editors because these are the two I've only ever really used.

MrMojoRisin5
MrMojoRisin5
  • Member since: Jun. 21, 2011
  • Offline.
Forum Stats
Member
Level 12
Programmer
Response to Python to Mac .app 2013-06-24 13:18:02 Reply

Since you posted your response, I've been reading about this. I've tried AppleScript, Xcode, none of them work. Do you have any ideas?


-Got to keep on risin'...
-Check out FlashFrame
-Check out my YouTube channel and my blog

BBS Signature
kiwi-kiwi
kiwi-kiwi
  • Member since: Mar. 6, 2009
  • Offline.
Forum Stats
Member
Level 09
Programmer
Response to Python to Mac .app 2013-06-24 13:26:59 Reply

At 6/24/13 01:18 PM, MrMojoRisin5 wrote: Since you posted your response, I've been reading about this. I've tried AppleScript, Xcode, none of them work. Do you have any ideas?

yes, use deflate algorithm from libz to archive everything into your app, inflate to unarchive somewhere in a temporary directory, run python from your app on the main script in your temporary directory, delete directory when you're done.

Or you could just tell people to run it with python stuff.py from a terminal, it's really not that much of a bother
MrMojoRisin5
MrMojoRisin5
  • Member since: Jun. 21, 2011
  • Offline.
Forum Stats
Member
Level 12
Programmer
Response to Python to Mac .app 2013-06-24 13:36:49 Reply

At 6/24/13 01:26 PM, kiwi-kiwi wrote: yes, use deflate algorithm from libz to archive everything into your app, inflate to unarchive somewhere in a temporary directory, run python from your app on the main script in your temporary directory, delete directory when you're done.

I didn't understand any of this...could you please explain it?

Or you could just tell people to run it with python stuff.py from a terminal, it's really not that much of a bother

Yeah, but an .app file would be much more convenient and would attract more people.


-Got to keep on risin'...
-Check out FlashFrame
-Check out my YouTube channel and my blog

BBS Signature