【问题标题】:how to make pytesser (Tesseract) work?如何使 pytesser (Tesseract) 工作?
【发布时间】:2014-09-28 12:46:52
【问题描述】:

我正在尝试让 pytesser(可下载 here)在我的 mac OS 上运行,但我没有成功。

我安装了 Tesseract、PIL 和所有依赖项。

我在我的python lib文件夹中解压了pytesser并将脚本文件修改为__init__.py 在初始化文件中,我按照建议的herehere 修改了tesseract.exe 文件的路径 那就是:

tesseract_exe_name = 'my lib path/pytesser/tesseract' # Name of executable to be called at command line

这就是我得到的错误:

Traceback (most recent call last):
  File "<pyshell#50>", line 1, in <module>
    print image_to_string(picz)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pytesser/__init__.py", line 31, in image_to_string
    call_tesseract(scratch_image_name, scratch_text_name_root)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pytesser/__init__.py", line 21, in call_tesseract
    proc = subprocess.Popen(args)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 679, in __init__
    errread, errwrite)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1228, in _execute_child
    raise child_exception
OSError: [Errno 8] Exec format error

该模块似乎无法运行 .exe 文件。我尝试更改路径,添加扩展名 .exe,但总是遇到同样的错误。

【问题讨论】:

  • 您可能正在执行错误的二进制文件。您可以手动尝试 tesseract 命令吗? (即在 shell 中键入 tesseract 并查看它是否有效)。如果可行,请使用which tesseract 的结果作为tesseract_exe_name 变量的输入。
  • 问题是我在 Mac 上运行。所以我不知道如何从这里运行 .exe 文件。我想这就是 subprocess.Popen 正在尝试做的事情。现在我正在尝试另一个 Tesseract wrapper 希望有更多的运气。
  • 问题不在于 tesseract 包装器,而在于 tesseract 二进制文件。您不在 Mac 上运行 .exe,而是运行二进制文件的 mac 版本。第一步是让 tesseract 运行,第二步可以从 Python 访问它。
  • @Wolph 谢谢,这正是我现在要做的 :) 我发现 this linkthis one 对于安装和运行 Tesseract 很有用(我以为我已经安装了它,但我不确定我是否成功了.. 现在我正在尝试使用不同的语言包,我希望它会起作用)一个问题:我可以将该包装器用于 Mac 版本的 Tesseract 还是只能在 Windows 版本上使用?跨度>
  • 更新:我尝试以各种方式安装 python-tesseract:wget python-tesseract.googlecode.com/files/… sudo tar zxvf python-tesseract.macosx-10.8-intel.tar.gz -C /opt/local AND svn checkout python-tesseract.googlecode.com/svn/trunk python-tesseract cd python-tesseract sudo port install py27-coverage python setup.py clean python setup.py build python setup.py install 但我总是遇到同样的错误:

标签: python macos tesseract pytesser


【解决方案1】:

python tesseract 包装器的几种解决方案:

Python-Tesseract

首先获取 homebrew 并 brew install python,然后 easy_install https://bitbucket.org/3togo/python-tesseract/downloads/python_tesseract-0.9.1-py2.7-macosx-10.10-x86_64.egg

来源:https://code.google.com/p/python-tesseract/wiki/HowToCompileForHomebrewMac

pytesseract

这是我在获得 python-tesseract 之前使用的,pip install pytesseract。然后你必须去/usr/local/lib/python2.7/site-packages然后去pytesseract然后pytesseract.py。将 python 脚本中的文件路径更改为 tesseract 在您的计算机上的位置。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多