在Google Colab中将图像转换为文本时,出现TesseractError:(2,“用法:pytesseract [-l lang] input_file”)错误

时间:2020-03-17 07:49:10

标签: python machine-learning computer-vision ocr

下面是我的代码

im=Image.open("/root/ppm_to_jpg/6e196d3b-adec-45ab-b036-5833f96f1bc0-2.jpg")
pytesseract.pytesseract.tesseract_cmd = r'/usr/local/bin/pytesseract'
text=pytesseract.image_to_string(im,lang="eng")
print (text)

我得到了错误提示,例如TesseractError:(2,“用法:pytesseract [-l lang] input_file”)

有人可以建议我该怎么做

1 个答案:

答案 0 :(得分:0)

!sudo apt install tesseract-ocr

以上安装了pytesseract所需的依赖项。这非常重要,尤其是!没有它们,您将无法直接安装到基础操作系统。

!pip install pytesseract

这将安装Python绑定。

希望这会有所帮助。