I have working code in which I use tesseract to extract data from image file, as follows:
if src:
driver.get(src)
driver.save_screenshot('/Users/username/script/' + 'test.png')
image_name = 'test.png'
im = Image.open(image_name)
image_text = pytesseract.image_to_string(im)
print '\nImage Text:\t', image_text
This code snippet works without any error in Mac terminal when I execute code but when I do the same in Eclipse using PyDev, it throws an error:
Exception: [Errno 2] No such file or directory
when trying to execute the line:
im = Image.open(image_name)
Why is this happening in Eclipse?
UPDATE: Since my code seemed funky to few people, I have changed it as following but the issue still remains (runs perfectly fine on mac terminal but Eclipse keeps giving me same error)
if src:
driver.get(src)
image_name = 'test.png'
image_path = os.path.realpath(image_name)
driver.save_screenshot(image_path)
# read chart data from image
im = Image.open(image_path)