python Hide Terminal Execution Method of cmd Command
- 2021-06-29 11:32:31
- OfStack
You don't want the following terminal command boxes after packaging with pyinstaller, but adding the -w or -noconsole commands during packaging can cause the cmd program to fail and cause errors.subprocess can solve this kind of problem at this time.
import subprocess
cmd = 'your command'
res = subprocess.call(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
In this way, the packaged program will not have a command box and will run normally.