droledenom
droledenom

Reputation: 225

No module named pytesseract error

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 ?

Upvotes: 5

Views: 13933

Answers (2)

rahul
rahul

Reputation: 73

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.

Upvotes: 0

coder3521
coder3521

Reputation: 2646

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 .

Upvotes: 5

Related Questions