【问题标题】:Pytesseract image to string error messages in ColabPytesseract 图像到 Colab 中的字符串错误消息
【发布时间】:2021-11-23 14:46:51
【问题描述】:

在我的 Colab 中安装并导入 pytesseract 为:

!pip install pytesseract
import pytesseract
import cv2

加载图片:

image = cv2.imread('drive/MyDrive/test.png')

然后我会收到这条消息:(2, 'Usage: pytesseract [-l lang] input_file') 如果我将代码编写为:

pytesseract.pytesseract.tesseract_cmd = r'/usr/local/bin/pytesseract'
text = pytesseract.image_to_string(image)

这条消息:/usr/bin/tesseract 未安装或不在您的 PATH 中。有关详细信息,请参阅 README 文件。 如果我写:

pytesseract.pytesseract.tesseract_cmd = (r'/usr/bin/tesseract')
text = pytesseract.image_to_string(image)

您知道为什么以及如何解决它吗?如果您需要更多信息,请告诉我。

【问题讨论】:

  • 你是如何安装 Tesseract 的?要安装的不仅仅是 Python 模块。请参阅此处的示例:colab.research.google.com/github/mepky/image_processing-opencv-/…
  • 哦,谢谢,在开头加上“!sudo apt install tesseract-ocr”,我就可以使用Tesseract了。我安装不正确,不是吗?我怎样才能支持你的答案?
  • 好的,很高兴它正在工作。我添加了一个答案——而不仅仅是评论——所以你可以接受/投票。

标签: python google-colaboratory python-tesseract


【解决方案1】:

请确保您已安装 Python 模块正在利用的底层库,例如:

!sudo apt install tesseract-ocr

# then you can do: 
!pip install pytesseract

【讨论】:

  • 对不起,我按下了按钮,但它说:“感谢您的反馈!您需要至少 15 声望才能投票,但您的反馈已被记录”。当我有足够的“声誉”时,我会再试一次。我是这里的新成员。
  • 哦,知道了。您应该能够通过投票箭头下方的复选标记接受答案。这将向该网站的其他用户表明您的问题得到了满意的回答。编码愉快!
  • 快乐编码^^
猜你喜欢
  • 1970-01-01
  • 2018-08-23
  • 2021-06-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-10-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多