7

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

import Image
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.

mirekphd
  • 4,799
  • 3
  • 38
  • 59
Jase Villam
  • 2,895
  • 6
  • 18
  • 21
  • You need to install a C library that should be available here http://www.leptonica.org/download.html ; if you are using brew, `brew install leptonica` might help. – J.J. Hakala Jan 24 '16 at 22:39
  • I tried `pip install leptonica` but received another error `Could not find a version that satisfies the requirement leptonica (from versions: ) No matching distribution found for leptonica` – Jase Villam Jan 25 '16 at 00:19
  • 1
    If `pip install leptonica` was possible, `pip install tesseract-ocr` would do that automatically. – J.J. Hakala Jan 25 '16 at 00:23

5 Answers5

14

You need install libtesseract-dev in your system;

sudo apt install libtesseract-dev
Smart Manoj
  • 5,230
  • 4
  • 34
  • 59
yinzhedfs
  • 141
  • 1
  • 4
2

Use this with yum:

yum install leptonica-devel tesseract-devel
Sagi Mann
  • 2,967
  • 6
  • 39
  • 72
1

In Linux Use the Following Command

sudo apt-get install tesseract-ocr
Sandeep PS
  • 63
  • 7
1

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.

crifan
  • 12,947
  • 1
  • 71
  • 56
  • I was still getting an error after doing this. Before using tesseract in code, I had to set the path of my tesseract installation to a variable, as shown in this answer: https://stackoverflow.com/a/54995964/14068350 – Shad Mar 23 '22 at 00:56
0

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

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – lpounng Apr 28 '22 at 09:08