简体   繁体   中英

Python Subprocess Popen with Pyinstaller

I use ffmpeg for converting some videos. I am calling command with subprocess.Popen(...)

si = subprocess.STARTUPINFO()
si.dwFlags |= subprocess.STARTF_USESHOWWINDOW

self.my_pro = subprocess.Popen(cmd,
stdin=subprocess.PIPE,
stderr=subprocess.PIPE,
startupinfo=si)

(output, error) = self.my_pro.communicate()

and i kill with this method

self.my_pro.kill()

It's okey without compile to exe.

But i compiled with pyinstaller with --noconsole subprocess not working. I must change subprocess.Popen(...) to subprocess.check_output(...)

But this time i can't kill process with self.my_pro.kill() this not working.

How i can run process with i can kill and it will run pyinstaller noconsole?

As @jfs wrote, with Popen you have to redirect everything. You forgot stdout

So this code doesn't crash for me anymore:

si = subprocess.STARTUPINFO()
si.dwFlags |= subprocess.STARTF_USESHOWWINDOW

self.my_pro = subprocess.Popen(cmd,
stdin=subprocess.PIPE,
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
startupinfo=si)

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