python - 我在 python 中使用 tesseract 包时遇到错误

标签 python python-tesseract

我正在尝试使用 pytesseract OCR 读取支票中的文本。我已经安装了此任务所需的 python 包,例如pip 安装 pytesseract。

但是,当我尝试使用该包读取文件时,出现以下错误:

 pytesseract.image_to_string(im, lang='eng')
Traceback (most recent call last):

  File "<ipython-input-17-d7d9f430493b>", line 1, in <module>
    pytesseract.image_to_string(im, lang='eng')

  File "C:\Users\BRIGHT\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 294, in image_to_string
    return run_and_get_output(*args)

  File "C:\Users\BRIGHT\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 202, in run_and_get_output
    run_tesseract(**kwargs)

  File "C:\Users\BRIGHT\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 172, in run_tesseract
    raise TesseractNotFoundError()

TesseractNotFoundError: tesseract is not installed or it's not in your path

这个错误没有意义,因为我实际上导入了包而没有收到任何错误。但当我尝试使用它时,出现错误。

这是我的代码:

from PIL import Image
import pytesseract

im=Image.open('BritishChequeAnnotated.jpg')
text=pytesseract.image_to_string(im, lang='eng')

最佳答案

tesseract 的文档清楚地说明了这一点。

https://pypi.org/project/pytesseract/

# If you don't have tesseract executable in your PATH, include the following:
pytesseract.pytesseract.tesseract_cmd = r'<full_path_to_your_tesseract_executable>'

关于python - 我在 python 中使用 tesseract 包时遇到错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52929872/

相关文章:

python - 捕获单词并重写

python - 在手写数字示例中使用 scikit-learn 实现 SVM 的特征提取器

python - 将字符串作为资源嵌入

ocr - 如何在 pytesseract 中使用经过训练的数据?

Python + OpenCV + Pytesseract 建议

iterator - Python 中的可迭代性

python - 如何使用python实现alpha matting算法

python - 使用 pytesseract 从图像生成 PDF

python - 如何计算OCR系统的置信度得分?

Python 检测字符 tesseract ocr 使用 pytesseract 为文本创建 blob