Making a PyInstaller exe do both command-line and windowed Making a PyInstaller exe do both command-line and windowed windows windows

Making a PyInstaller exe do both command-line and windowed


This is not a perfect solution, but this workaround did the job for me:

Build gui app in --noconsole --one file mode like this:

pyinstaller --noconsole --onefile hello.py

When you double click on the app from windows it will launch normally (without the console).

Now to see the output, navigate to the executable from the command line and type:

hello.exe | more

The "| more" should send the print statements to the console.


This is a problem with Windows (not PyInstaller), which requires the subsystem to be specified as either CONSOLE or WINDOWS at compilation-time.

The recommended solution is to split your app (eg hello) into two distinct versions:

  1. hellow.exe for the GUI version (windowed) and
  2. hello.exe for the CLI version (console)

In theory, you could also add a wrapper .exe that switches between the two actual binaries above, depending on how it's called..