5

I am trying to use pytesseract for OCR, on a raspberry pi using Raspbian

I have read several questions on this topic, but can't find an answer that works, they usually say to install pytesseract with pip, and I did it.

my code is very simple:

import pytesseract
from PIL import Image
print(pytesseract.image_to_string(Image.open('test.jpg')))

But it returns error message : "ImportError: No module named 'pytesseract' .

I have installed tesseracrt-ocr (the whereis tesseract-ocr command returns /usr/share/tesseract-ocr)

I have installed pytesseract with pip install tesseract (which returns successfully installed Pillow-4.3.0 olefile-0.44 pytesseract-0.1.7 ... but the whereis pytesseract command does not return anything --> a problem?).

Do you have any idea of the problem I have ?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
droledenom
  • 207
  • 2
  • 6
  • 18

2 Answers2

5

See after installing pytesseract ,using

<cmd>C:\> pip install pytesseract

Try :

import pytesseract

If above is not working then it has do something with the installation , Check if pytesseract folder is available under "\Python27\Lib\site-packages" ,

Try the above command from site packages, Hope this helps , Else there is something wrong with installation .

coder3521
  • 2,608
  • 1
  • 28
  • 50
0

Add this line in your code

pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'

set your path where tesseract-ocr is installed and also add this path to your window environment variable.Also check this link Tesseract installation for complete installation of tesseract.

rahul
  • 53
  • 4
  • Could you explain a bit more why this line solves the issue? – mpSchrader Oct 16 '20 at 08:09
  • pytesseract does not work by only pip install. https://pypi.org/project/pytesseract/ check this link for complete installation of tesseract.This line of code specify the path of tesseract ..if the path is not set it throws the error tesseract is not in the path. – rahul Oct 16 '20 at 09:40