简体   繁体   中英

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 ?

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 .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM