Bundled Python 3.5.1 app crashes when reading text files on Mac OS X

时光毁灭记忆、已成空白 提交于 2019-12-24 15:40:27

问题


I have built an app using Python 3.5.1 and PyQt 5.6 under Mac OS X 10.11.4. Everything runs fine unbundled.

I have bundled it using Pyinstaller 3.2. Everything seems to work fine until the app reads text files from disk. File access is not the problem, since I can read all file properties using libmagic, which I do in order to filter out unwanted input formats, as these are user-selected files to be processed by my app.

The bundled app crashes exactly when the content of a text file is read into a variable in the usual way: text = fobj.read(). The prior file opening statement is successful, though.

To make things even more weird, this doesn't happen when the app is started from the terminal with the open command, only when it's started by double-clicking the app file. I have been reading about how Mac OS X treats app execution in these two ways, but apparently there should be no difference, as stated in the man page for the open command:

The open command opens a file (or a directory or URL), just as if you had double-clicked the file's icon.

I have been struggling with this issue for days and cannot find a solution. I need to distribute my application, but asking users to start it from the terminal is not very appealing... Any help greatly appreciated.

来源:https://stackoverflow.com/questions/37168675/bundled-python-3-5-1-app-crashes-when-reading-text-files-on-mac-os-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!