as far as I understand, there is no “problem” here. at least with the python program.
when executing the “composite” command, команда1 | команда2
команда1 | команда2
shell creates two processes — one to execute command1 , the second to execute command2 , and the stdout of the first process connects with a pipe (pipe, pipeline) to the stdin of the second process.
if the second process completes earlier than the first, then for the first process the “pipe” is “broken pipe”.
in your case, this is exactly what happens: the program (or the built-in function) echo “is not at all interested” in the contents of its stdin , prints an empty line to its stdout and ends. and the python program, having gone through a “long and painful” (in comparison with echo ) loading procedure, finally discovers that “the pipe is broken”. what you and reports. This message it gives to stderr , which is not connected with any “pipes” (it is sent directly to the pseudo-terminal created by the shell), and therefore this message safely reaches your eyes.