1

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 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

2 Comments

The console variable value is False in the SPEC file. The console does not appear when you first open the file. But when the program runs to the execute command line (ex: gradle check) the console will appear at this time.
When you execute a command (say via OS), the python process opens up a new console. To stop that you need to edit the python code. What are using to spawn gradle check?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.