I have an Electron app xxx.exe
which is spawning an executable created from PyInstaller yyy.exe
. In, yyy.exe
, I am finally trying to launch a git
cmd via subprocess.check_output()
.
Sadly, the call to check_output()
throws [WinError 6] The handle is invalid
.
If yyy.exe
is directly launched on the command line, everything is running fine.
The issue is only happening on Windows. My assumption is that there are some checks on stdin
that trigger the exception because running through an Electron app doesn't provide any Stdin.
Any hints would be appreciated! Thanks in advance!
On Windows, subprocess.Popen
tries to duplicate non-zero standard handles and fails if they're invalid. You can redirect stdin
and stderr
to NUL. For example:
import os
try:
from subprocess import DEVNULL
except ImportError:
DEVNULL = os.open(os.devnull, os.O_RDWR)
output = subprocess.check_output(cmd, stdin=DEVNULL, stderr=DEVNULL)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With