0

I'm trying to make pytesser (downloadable here) work on my mac OS, but I don't succeed.

I installed Tesseract, PIL and all the dependencies.

I unzipped pytesser in my python lib folder and modified the script file into __init__.py in the init file I modified the path to the tesseract.exe file as suggested here and here that is:

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

that's what I get as error:

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

it seems that the module does not manage to run the .exe file. I tried to change the path, add the extension .exe but I always get the same error.

Community
  • 1
  • 1
DaniPaniz
  • 1,058
  • 2
  • 13
  • 24
  • You are probably executing the wrong binary. Can you try the tesseract command manually? (i.e. type `tesseract` in a shell and see if it works). And if that works, use the result of `which tesseract` as the input for the `tesseract_exe_name` variable. – Wolph Sep 28 '14 at 12:53
  • the problem is that I'm running on a Mac. So I don't know how to run an .exe file from here. I guess that that is what subprocess.Popen is trying to do.. Now I'm trying another [Tesseract wrapper](https://code.google.com/p/python-tesseract/) hoping to have more luck. – DaniPaniz Sep 28 '14 at 15:38
  • The problem isn't in the tesseract wrapper, it's in the tesseract binary. You don't run a .exe on a mac, you run the mac version of the binary. Step one here is getting tesseract running, step 2 could be accessing it from Python. – Wolph Sep 28 '14 at 15:57
  • @Wolph thanks, that's exactly what I'm trying to do now :) I found [this link](http://maconenine.blogspot.de/2010/11/installing-tesseract-on-mac-osx.html) and [this one](http://samkhan13.wordpress.com/2013/07/18/installing-python-tesseract-on-mac-os-x/) useful for installing and running Tesseract (I thought I already installed it but I'm not sure I managed.. now I'm trying it out with different language packages, I hope it will work) One question: can I use that wrapper for the Mac version of Tesseract or that would only work on a Windows version? – DaniPaniz Sep 28 '14 at 16:38
  • update: I tried to install python-tesseract in various ways: wget http://python-tesseract.googlecode.com/files/python-tesseract.macosx-10.8-intel.tar.gz sudo tar zxvf python-tesseract.macosx-10.8-intel.tar.gz -C /opt/local AND svn checkout http://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 but I always get the same error: – DaniPaniz Sep 28 '14 at 16:59
  • P.s. I tested tesseract by itself, it works. It's the wrapper that doens't work :/ neither of the two. – DaniPaniz Sep 28 '14 at 17:02
  • If tesseract works, try what I first suggested (running `which tesseract` from a terminal) and fill that into the `tesseract_exe_name` variable – Wolph Sep 29 '14 at 15:25

1 Answers1

0

Several solutions for a python tesseract wrapper:

Python-Tesseract:

First of get homebrew and brew install python, then easy_install https://bitbucket.org/3togo/python-tesseract/downloads/python_tesseract-0.9.1-py2.7-macosx-10.10-x86_64.egg

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

pytesseract:

This what I was using previously before getting python-tesseract, pip install pytesseract. Then you have to go to /usr/local/lib/python2.7/site-packages and go to pytesseract then pytesseract.py. Change the file path in the python script to where tesseract is located on your computer.

boisvert
  • 3,679
  • 2
  • 27
  • 53