简体   繁体   中英

Python: Hide console when executing the command line

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?

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.

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