python-3.x - BrokenPipeError:-Errno- 32 损坏的管道
问题描述
我收到 BrokenPipeError: [Errno 32] Broken pipe 错误。我不知道我做错了什么
我添加shell=True
是因为我有一个不同的错误:FileNotFoundError: [WinError 2]
from collections import Iterable
import io
import re
import subprocess
import cv2
def ocr(img):
ok, buf = cv2.imencode(".bmp", img)
if not ok:
raise Exception("Cannot encode image")
args = ["/usr/bin/tesseract", "stdin", "stdout", "-l", subtitles_lang]
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, shell=True)
p.stdin.write(buf)
p.stdin.close()
控制台显示这个
Aligning videos on 5 frames...
pos_diff_sec=0.0
Writing eng subtitles to subtitles.srt...
00:00:02,293 (3.10) - 00:00:03,837 (7.40) Traceback (most recent call last):
File "C:/Users/simon/Documents/meltsub-master/meltsub-master/meltsub.py", line 264, in <module>
extract_subs(f, softsub_video, hardsub_video, pos_diff_sec)
File "C:/Users/simon/Documents/meltsub-master/meltsub-master/meltsub.py", line 229, in extract_subs
text = ocr(sub_frame)
File "C:/Users/simon/Documents/meltsub-master/meltsub-master/meltsub.py", line 115, in ocr
p.stdin.write(buf)
BrokenPipeError: [Errno 32] Broken pipe
Process finished with exit code 1
如果需要,我可以发布更多代码
解决方案
推荐阅读
- angular - 解析服务后,Angular2,3,4 observable 返回 true false
- c - 如何将链接列表保存到文件中,并将“数据”归档为结构
- pandas - 日期序号和日期需要转换成日期格式
- statistics - Matrix with simplex columns in stan
- vue.js - 如何更改 v-btn 的状态(视觉上)以便在模板中选择/取消选择它?
- java - 如何在不重新部署的情况下更改 weblogic 中的属性值?
- python - How to use list of numpy arrays to train ML algorithm?
- java - 模拟助手类方法和返回布尔值
- php - 如何解决这个错误:explode() 期望参数 2 是字符串,给定对象?
- python - 使用 self 或 type(self) 调用类中的静态方法和类方法