'gcc error on install of tesseract-ocr

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.



Solution 1:[1]

You need install libtesseract-dev in your system;

sudo apt install libtesseract-dev

Solution 2:[2]

Use this with yum:

yum install leptonica-devel tesseract-devel

Solution 3:[3]

In Linux Use the Following Command

sudo apt-get install tesseract-ocr

Solution 4:[4]

refer another post, final solution on my Mac:

brew install tesseract

explanation:

it will install backend tesseract and dependent lib leptonica (and others libs: giflib, jpeg, libpng, libtiff, little-cms2, openjpeg, webp), so can fix this error.

Solution 5:[5]

try it like this without using space in between "pip install easyocr"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Smart Manoj
Solution 2
Solution 3 Sandeep PS
Solution 4 crifan
Solution 5 user18971583