0

I am trying to extract text from an image using Tesseract. Here is my code. I installed using pip install pytesseract and I also checked pytesseract.py under site-package. But when I run the following code, I got the following error message 'WindowsError: [Error 2] The system cannot find the file specified'.

Any ideas? Thanks

from PIL import Image
import pytesseract
#pytesseract.pytesseract.tesseract.cmd = 'C:/Program Files (x86)/Tesseract-OCR/tesseract.exe'
im = Image.open('C:/Users/daizhang/Desktop/issue.PNG')
text = pytesseract.image_to_string (im)
print (text)
Max Worg
  • 2,932
  • 2
  • 20
  • 35
Dai Zhang
  • 11
  • 1
  • 2
  • I believe your only issue is that the file can't be found on the computer (the error message says that it can't find the file). Make sure that path to issue.png is correct (have you verified that it is on the desktop?). The issue does not seem to be with pytesseract but with the location of the file you are trying to load into PIL. – Max Worg Oct 25 '17 at 04:40
  • I don't think its simple path issue. This issue is being discussed on `pytesseract` github @ https://github.com/madmaze/pytesseract/issues/50 with some possible work-around, although the workaround didnt work for me when I tried. – Anil_M Oct 25 '17 at 05:48
  • @Anil_M Thanks for replying. It seems I had a typo... if I include commenting off line and change tesseract.cmd to tesseract_cmd, then it works fine. – Dai Zhang Oct 25 '17 at 15:48
  • You may check the answer in this [Pytesseract Image_to_string returns Windows Error: Access denied error in Python](https://stackoverflow.com/questions/46567157/pytesseract-image-to-string-returns-windows-error-access-denied-error-in-python) – thewaywewere Oct 26 '17 at 19:50

1 Answers1

0

I understand that there is not enough information in the error. But you need to install Tesseract-OCR

And also make sure the installation directory in your system path.

Hax0
  • 103
  • 2
  • 8