IOError: [Errno 32] Broken pipe when piping: `prog.py | othercmd`
I haven't reproduced the issue, but perhaps this method would solve it: (writing line by line to stdout
rather than using print
)
import sys
with open('a.txt', 'r') as f1:
for line in f1:
sys.stdout.write(line)
You could catch the broken pipe? This writes the file to stdout
line by line until the pipe is closed.
import sys, errno
try:
with open('a.txt', 'r') as f1:
for line in f1:
sys.stdout.write(line)
except IOError as e:
if e.errno == errno.EPIPE:
# Handle error
You also need to make sure that othercommand
is reading from the pipe before it gets too big - https://unix.stackexchange.com/questions/11946/how-big-is-the-pipe-buffer
Python3 - [Errno 32] Broken Pipe while using sockets
your server is closing the port immediately after a single recv
. I'd suggest changing your handle_client
code to have some sort of while
loop that ends when recv
returns an empty string (this indicates the client has shutdown
their end of the connection, probably by close
ing their connection)
IOError: [Errno 32] Broken pipe when saving animation files in anaconda python
Get it solved by myself! I use conda install to get ffmpeg but when using ffmpeg --version will always say that:
libssl.so.10: cannot open shared object file: No such file or directory
so I use:
sudo ln -s /home/xin/anaconda2/lib/libssl.so.1.0.0 libssl.so.10
Then get similar problem about libcrypto.so.10, so I use:
sudo ln -s /home/xin/anaconda2/lib/libcrypto.so.1.0.0 libcrypto.so.10
The two files are in /lib/x86_64-linux-gnu.
Now things work!! I know some people also have similar problems, so I record it here.
In future, if need to remove the link:
cd /lib/x86_64-linux-gnu
sudo unlink libssl.so.10
sudo unlink libcrypto.so.10
Related Topics
Why Am I Getting Ioerror: [Errno 13] Permission Denied
How to Find the Maximum Consecutive Occurrences of a Number in Python
Python Super :Typeerror: _Init_() Takes 2 Positional Arguments But 3 Were Given
Convert a Python Int into a Big-Endian String of Bytes
How to Increase the Font Size of the Markdown Table in Jupyter Notebook
How to Tell If Tensorflow Is Using Gpu Acceleration from Inside Python Shell
How Do Convert a Pandas Dataframe to Xml
In Python, How to Check If Selenium Webdriver Has Quit or Not
Formatting Datetime Xlabels in Matplotlib (Pandas Df.Plot() Method)
Get Character Position in Alphabet
Open() Gives Filenotfounderror/Ioerror: Errno 2 No Such File or Directory
How to Populate New Column Based on Values in Other Columns
How to Pass a .Txt File to a Function in Python
How to Replace Negative Numbers in Pandas Data Frame by Zero
Pandas - Find Index of Value Anywhere in Dataframe
Print the Lines of a Log File Which Starts With Date Format "Yyyy-Mm-Dd" in Python