Python: Hide console when executing the command line

Viewed 82

I have a python script that contains code to execute the command line. I generated .exe file from this script using pyinstaller. This is the command I use to freezes my python script:

pyinstaller --onefile --noconsole sriptName.py

When I open my exe file. The console still opens and shows the output of the command line executed in my script

How can I hide this console?

1 Answers

When you run PyInstaller on your project, does a .SPEC file also appear?

If so, edit the .SPEC file's exe field like so:

exe = EXE(
      ...,
      console=False,
      ...
      )

Then run PyInstaller on the .SPEC file.

If a .SPEC file didn't appear before, try running PyInstaller on your project without any parameters (so just pyinstaller myProgram.py). A .SPEC file should appear and you can edit it as above and then rerun PyInstaller.

Related