简体   繁体   中英

mac os x app bundle built from pyinstaller doesn't work correctly

I used PyInstaller to build a mac os x app bundle for my python2.7 package. Double clicking the app icon momentarily popped up the console window but disappeared right away. However, double clicking the expanded "Contents/MacOS/executable" correctly popped up the expected window.

Following is a screen short for my expanded app contents. The Frameworks folder is empty, the Resources folder contains the icon, and the MacOS folder contents all the binary libraries and the executable (which is running ok as stated above). Not sure whether modifying the info.plist will help or not.

在此处输入图片说明

Did you try using the -w flag? From the docs:

-w, --windowed, --noconsole

Use a windowed subsystem executable, which on Windows does not open the console when the program is launched. This option is mandatory when creating .app bundle on Mac OS X.

I am not sure what this means: "Application is background only = YES" ?

I tried to replicate your problem with my app foo and the ...947 build of Pyinstaller (a recent, dev version.) I used --onefile --windowed args to Pyinstaller. I found that in the Finder, double clicking build/foo starts a console, and then the app window appears. While double clicking the bundle build/foo.app did not seem to start a console, and my app window appears. In other words, it works for me.

On the other hand, I tried another packager: Whitebox Packages In creating a package, I put the pyinstaller/foo/build/foo file (the executable) into the bundle. Etc. 'Packages' created a .mpkg file for me, which I installed. Then, when I invoked my app, a console did appear, and them my app's window. (Which is not good, I don't want a console.) I don't understand what attributes of the package make the app start without a console. I don't think it is the case that the executable include a shell that starts a console, it must be OSX that is starting the console.

Probably, it is not a high priority of the PyInstaller project to do 'packaging for distribution' correctly, since other tools exist.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM