我正在尝试从此命令获取输出:“hocr-pdf” 因此,当我在命令行中运行此命令时,它运行得非常好,这就是我输入的方式:
hocr-pdf . > converted.pdf
为了让这个命令工作,我必须在工作目录中有2个带有这些扩展名的文件(jpeg,hocr) 因此,当尝试运行包含此命令的此脚本时,它会向我显示:
hocr-pdf: error: unrecognized arguments: gg
这是我的代码:
from enter_filename import f2files
from f1fileOpen import f1file
from findPDF import OCRized
import subprocess
a =f1file()
if not OCRized(a):
p1=subprocess.check_call(["convert","-density","300",a,"-depth","8","converted.jpg"])
print "Conversion to jpg was successful"
p=subprocess.check_call(["tesseract","converted.jpg",'converted',"-l","eng","hocr"])
print "tesseract done the job"
p2=subprocess.check_call(["hocr-pdf",".>","gg"])
else:
p=subprocess.check_call(["tesseract",'1.png','f1',"-l","eng"])
答案 0 :(得分:1)
当您使用shell功能时,您应该使用以下命令调用shell:
p2=subprocess.check_call(["bash","-c","hocr-pdf .> gg"])