image_to_string no funciona en Mac
-
21-12-2019 - |
Pregunta
Estoy tratando de seguir este ejemplo de Pytesser ( enlace ) enun Mac Maverick.
>>> from pytesser import *
>>> im = Image.open('phototest.tif')
>>> text = image_to_string(im)
Pero, en la última línea, obtengo este mensaje de error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pytesser.py", line 31, in image_to_string
call_tesseract(scratch_image_name, scratch_text_name_root)
File "pytesser.py", line 21, in call_tesseract
proc = subprocess.Popen(args)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1308, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Pero, no entiendo lo que debería hacer.El archivo fototest está en la misma carpeta que ejecuto el script.¿Cómo arreglar esto?
Actualización:
cuando lo intento
brew install tesseract
Obtengo este error:
Warning: It appears you have MacPorts or Fink installed.
Software installed with other package managers causes known problems for
Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again.
Error: You must `brew link libtiff libpng jpeg' before tesseract can be installed
Solución
En realidad tuve el mismo error que tú, que es cómo encontré esta publicación. ¡También tengo la solución a mi problema, porque me lo diste!
Estaba viendo:
ryan.davis$ python tesseract.py
Traceback (most recent call last):
File "tesseract.py", line 52, in <module>
print (image_to_string(big))
File "/usr/local/lib/python2.7/site-packages/pytesseract/pytesseract.py", line 161, in image_to_string
config=config)
File "/usr/local/lib/python2.7/site-packages/pytesseract/pytesseract.py", line 94, in run_tesseract
stderr=subprocess.PIPE)
File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
¿Quieres saber lo que tenía que hacer para arreglar esto? Exactamente lo que intentó: brew install tesseract
, había instalado la biblioteca de Tesseract Python, pero no lo había instalado a nivel del sistema. Así que eso resuelve mi problema. ¿Qué tal la tuya?
Creo que podría haber estado distraído por esto:
Advertencia: Parece que tiene MacPorts o Fink instalado. Software instalado con otros administradores de paquetes causa problemas conocidos para Homebrew. Si una fórmula no se basa, desinstale MacPorts / Fink e intente otra vez.
y no se notó que su respuesta ya se proporcionó en la respuesta de BREW:
Debe BREW LINK Libtiff Libpng JPEG antes de que Tesseract pueda ser instalado.
también:
brew link libtiff
brew link libpng
brew link jpeg
entonces:
brew install tesseract
Finalmente:
:)