Solve the problem of python executing no output system command pop box
- 2021-06-29 11:32:14
- OfStack
Recently, we made an GUI, because we called the system method in the os module. When packaging with pyinstaller, we chose not to output the system command pop-up box. The program can not run. It requires a system command box.Find a solution online.Use the subprocess.run() method.
Here is a simple example:
from time import sleep
from subprocess import run
for i in range(10):
sleep(1)
run("tree", shell=True)
# Because there are no balloons, this part is used to verify whether the program is executed
f = open("a.txt", "w")
f.close()
If the directory in which the executed file is located generates an "a.txt" file, the program executes successfully.