Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyInstaller OS X app runs from command line, but not Finder window

I have an application bundle created with PyInstaller on OS X. If I double click the .app bundle in Finder, the application tries to launch, then terminates. No further information is given in the console, other than the application quit.

But if I launch the app executable from the terminal (i.e., ./Contents/MacOS/MyApplication, it works perfectly fine. This seems to be the same behavior experienced in this issue: OSX app built with python quits immediately if app bundle is executed from finder but runs fine from command line, but the marked solution there isn't particularly helpful.

I suspect this is indeed related to an environment or path issue. But I'm not sure how to fix it. Should something be specified in the info.plist file maybe? Any guidance would be greatly appreciated.

like image 972
JoshG Avatar asked Oct 03 '14 09:10

JoshG


1 Answers

This is most likely due to a bad assumption about the working directory. When you launch from the Finder, the working directory may well be / (depends on OS X version), which is not writeable. If your app writes to the current working directory then you should probably set the working directory to somewhere sensible at startup.

like image 107
Paul R Avatar answered Dec 26 '22 23:12

Paul R