pyinstaller/pyinstaller

Terminal shown even with console=False on macOS

Closed this issue · 12 comments

Hi,

Thanks for making this great tool. I have a minor bug on macOS and I couldn't find it addressed in another issue.

I am working on a UI app with Gooey and am packaging it with PyInstaller (they recommend this BTW). On windows and linux, it seems to work well.

But on macOS, it shows the terminal even with console=False in the build.spec.

screen shot 2018-02-05 at 2 53 22 pm

Here's the build.spec: https://www.dropbox.com/s/i12e432z2bijhhs/build.spec?dl=0

On Windows, there is no terminal.

Thoughts? Is this a bug or misconfigured? Seems like a bug as it's inconsistent between the OSes.

Have you tried running pyinstaller from the command line using the command-line switches to have it generate a spec file for you? In my typical use of pyinstaller, it generates a spec file with more pyinstaller classes than your spec file shows. You can still edit the spec file afterwards if you need to.

Hi @itsayellow thanks for the info. I will give it a try and let you know.

Hello, Is this Issue Still Open?
if Yes Can you tell me what mac os version this is?
i am trying to reproduce it.

I am still experiencing the same issue.
MacOS version : macOS Catalina 10.15.6

my .spec file says console = False , but still it shows the terminal

@aashish-bidap can you copy-paste your spec file and eventual Info.plist?

I'm having the same issue on PyInstaller with MacOS. The spec file specifically states console=False, but the executable always has a console window as well as the main PyQt5 window.

I've attached an example spec file:
start_mac.zip

The command line call I'm using is:
python3 -m PyInstaller --noconsole --onedir --clean --windowed -y [path to spec file]
Taking the --windows section out has no effect.

This is on PyInstaller version 4.3 with pyinstaller-hooks-contrib version 2021.1, on MacOS 10.15.7.

Has anyone got any suggestions for why a console window would be continuing to appear please?

rokm commented

Taking the --windows section out has no effect.

That's because --noconsole and --windowed both do the same thing - they set console=False and trigger app bundle build on macOS.

Also

python3 -m PyInstaller --noconsole --onedir --clean --windowed -y [path to spec file]

--noconsole, --onedir, --windowed have no effect when you're running PyInstaller against .spec file. Only when you run it against .py, when they affect the auto-generated .spec.

That said, how are you launching your application?

The application has a console if it's run when double-clicked through Finder, but also when it's run through a subprocess.Popen() command from a separate Python script. Might the launch method be making a difference?

Thanks for confirming those parameters have no effect on the command line. console=False is already in the spec file, but as part of testing, I put them in the command line as well, for emphasis!

rokm commented

Might the launch method be making a difference?

Yes, if you are launching the binary itself instead of launching the .app bundle, you will get console. Only .app bundles are console-less.

rokm commented

To illustrate, suppose we have the following program:

# program.py
import sys
import signal

from PyQt5 import QtCore, QtWidgets

signal.signal(signal.SIGINT, signal.SIG_DFL)

app = QtWidgets.QApplication(sys.argv)

window = QtWidgets.QWidget()
window.setWindowTitle("Hello world!")
window.show()

app.exec_()

and we build it with:

pyinstaller  --clean --noconfirm --windowed program.py

This gives us dist/program (a "regular" onedir build) and dist/program.app (the onedir app bundle).

If we launch dist/program/program by double-clicking it in Finder, it opens console and displays the window. If we launch dist/program.app by double-clicking it in Finder, we get only window without console.

Massive thanks to @rokm for pointing this out. Coming from a Windows background, I hadn't realised the different behaviour was a difference between an .app and an executable. Sure enough, when running as an .app, it's console free! Facepalm time.

Thanks for your help.

rokm commented

It seems this issue is based on misunderstanding on what windowed/noconsole mode is supposed to do on macOS. The screenshot from the original report also implies that the author is trying to run the executable instead of the .app bundle, which results in the console being shown. As such, I'm closing this issue as invalid.