subprocess.Popen尝试写入不存在的管道

问题描述 投票:1回答:1

为什么以下不起作用?

import subprocess

process = subprocess.Popen('cmd.exe', shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=None)

我得到的输出如下:

The process tried to write to a nonexistent pipe.
The process tried to write to a nonexistent pipe.
The process tried to write to a nonexistent pipe.
The process tried to write to a nonexistent pipe.
The process tried to write to a nonexistent pipe.

此后,该过程将无错误终止。我正在运行Windows 7。

python subprocess popen
1个回答
1
投票
我正在运行Windows 10,并且遇到相同的问题。如果我将stdout和stderr设置为相同的值,该错误对我来说就消失了。尝试将它们都设置为subprocess.PIPE而不只是stdout。
© www.soinside.com 2019 - 2024. All rights reserved.