Error using Pytesser :**[WinError 2] The system cannot find the file specified**

Pranav V picture Pranav V · Jul 4, 2015 · Viewed 11.1k times · Source

I get this error: [WinError 2] The system cannot find the file specified, only when I use pytesser to do OCR. Here is my code snippet.

from PIL import Image
from pytesseract import *
image = Image.open('pranav.jpg')
print (image_to_string(image))****

Otherwise, when I use PIL to change size of image, I do not get this error.

Answer

elevated picture elevated · Jan 31, 2016

You don't have to edit any pytesseract files. You can declare the path to your Tesseract installation inside your code like so:

import pytesseract
pytesseract.pytesseract.tesseract_cmd = 'C:/Program Files (x86)/Tesseract-OCR/tesseract'