gcc error on install of tesseract-ocr

Jase Villam picture Jase Villam · Jan 24, 2016 · Viewed 7.3k times · Source

I am trying to run the following code on my mac.

import Image
enter code here`import pytesseract
im = Image.open('test.png')
print pytesseract.image_to_string(im)

Following the question from here: pytesseract-no such file or directory error I need to install tesseract-ocr

but when I try to pip install tesseract-ocr I get the following errors:

creating build/temp.macosx-10.5-x86_64-2.7
gcc -fno-strict-aliasing -I//anaconda/include -arch x86_64 -DNDEBUG -g
-fwrapv -O3 -Wall -Wstrict-prototypes -I//anaconda/include/python2.7 -c
tesseract_ocr.cpp -o build/temp.macosx-10.5-x86_64-2.7/tesseract_ocr.o
tesseract_ocr.cpp:264:10: 
fatal error: 'leptonica/allheaders.h' file not found #include "leptonica/allheaders.h"
     ^
1 error generated.
error: command 'gcc' failed with exit status 1

I don't know what to do.

Answer

yinzhedfs picture yinzhedfs · Sep 22, 2016

You need install libleptonica-dev and tesseract-ocr-dev in your system;

sudo apt install libleptonica-dev
sudo apt install tesseract-ocr-dev