如何使pytesser(Tesseract)工作?

时间:2014-09-28 12:46:52

标签: python macos tesseract pytesser

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

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

我在python lib文件夹中解压缩pytesser并将脚本文件修改为__init__.py 在init文件中,我按照建议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但我总是得到相同的错误。

1 个答案:

答案 0 :(得分:0)

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

<强> Python的超正方体

首先获取自制软件和brew安装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的位置。