PyInstaller OS X应用程序从命令行运行,但不在Finder窗口中运行 [英] PyInstaller OS X app runs from command line, but not Finder window

查看:39
本文介绍了PyInstaller OS X应用程序从命令行运行,但不在Finder窗口中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在OS X上使用PyInstaller创建了一个应用程序捆绑包.如果我在Finder中双击.app捆绑包,则该应用程序尝试启动,然后终止.除了退出应用程序以外,控制台中没有其他信息.

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.

但是,如果我从终端(即 ./Contents/MacOS/MyApplication )启动应用程序可执行文件,它就可以正常工作.这似乎是在此问题中遇到的相同行为:使用python构建的OSX应用程序退出如果应用程序捆绑包是从finder中执行的,但可以从命令行正常运行,则立即,但是标记的解决方案并没有特别的帮助.

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.

我怀疑这确实与环境或路径问题有关.但是我不确定该如何解决.是否应该在 info.plist 文件中指定某些内容?任何指导将不胜感激.

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.

推荐答案

这很可能是由于对工作目录的错误假设所致.从Finder启动时,工作目录很可能是/(取决于OS X版本),该目录不可写.如果您的应用程序写入当前工作目录,则可能应该在启动时将工作目录设置为明智的位置.

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.

这篇关于PyInstaller OS X应用程序从命令行运行,但不在Finder窗口中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆