【问题标题】:PyTesser simple usage errorPyTesser 简单使用错误
【发布时间】:2013-08-19 20:54:17
【问题描述】:

我已经下载了PyTesser 并解压了它。

我在pytesser_v0.0.1文件夹中,尝试在python解释器中运行sample usage代码:

from pytesser import *
print image_file_to_string('fnord.tif')

和输出:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pytesser.py", line 44, in image_file_to_string
    call_tesseract(filename, scratch_text_name_root)
  File "pytesser.py", line 21, in call_tesseract
    proc = subprocess.Popen(args)
  File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1259, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

注意:我在 Ubuntu 12.10Python 2.7.3

谁能帮我理解这个错误,我能做些什么来解决它?

【问题讨论】:

  • 如果你只是复制使用示例,我想你没有fnord.tif。使用磁盘上的图像并相应地更改代码。
  • fnord.tif 包括在内
  • 你加载 PIL 了吗?
  • 哦,那么对不起,我的错。您需要安装 tesseract。那是未找到的文件,call_tesseractPopen 的参数。 apt-get install tesseract-ocr.

标签: python ocr


【解决方案1】:

这并没有尽可能好地记录,但如果您不在 Windows 上,则需要为您的平台安装 tesseract 二进制文件。在 Ubuntu 和其他基于 Debian 的 Linux 发行版上,apt-get install tesseract-ocr。然后就可以运行了:

python pytesser.py

它使用测试文件phototest.tiffnord.tiffonts_test.png 来测试库。

【讨论】:

    【解决方案2】:

    对于 Windows 上的初学者使用 pytesseract:

    1. 打开命令提示符

    2. 类型:pip install pytesseract (这将在您的 python 上轻松安装 pytesseract 最新版本模块)

    3. 转到此链接并下载并安装 tesseract-ocr 引擎: https://code.google.com/p/tesseract-ocr/downloads/detail?name=tesseract-ocr-setup-3.02.02.exe&can=2&q=

    4. 现在您可以使用 pytesseract

    有关更多信息并查看代码示例,请查看此链接: http://www.manejandodatos.es/2014/11/ocr-python-easy/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-12
      相关资源
      最近更新 更多