madmaze / pytesseract

A Python wrapper for Google Tesseract
Apache License 2.0
5.83k stars 721 forks source link

raise TesseractError(proc.returncode, get_errors(error_string)) pytesseract.pytesseract.TesseractError: (3221225477, '') #260

Closed dipongkor closed 4 years ago

dipongkor commented 4 years ago

I am trying to execute following code

import pytesseract
from PIL import Image, ImageEnhance, ImageFilter
import os
image = Image.open("D:\\Bangla NLP\\OCR\\1.jpg")
pytesseract.pytesseract.tesseract_cmd = "C:\\Program Files (x86)\\Tesseract-OCR\\tesseract.exe"
tessdata_dir_config = '--tessdata-dir "D:\\Bangla NLP\\OCR"'
text = pytesseract.image_to_string(image, lang="ben", config=tessdata_dir_config)
print(text)

It is being ended up with the following error. I noticed same error in command line too. (pytesseract -l ben "D:\\Bangla NLP\\OCR\\2.jpg")

text = pytesseract.image_to_string(image, lang="ben", config=tessdata_dir_config) File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytesseract\pytesseract.py", PS D:\Bangla NLP\OCR> python -u "d:\Bangla NLP\OCR\ocr.py" Traceback (most recent call last): File "d:\Bangla NLP\OCR\ocr.py", line 7, in text = pytesseract.image_to_string(image, lang="ben", config=tessdata_dir_config) File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytesseract\pytesseract.py", line 350, in image_to_string }[output_type]() File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytesseract\pytesseract.py", line 349, in Output.STRING: lambda: run_and_get_output(*args), File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytesseract\pytesseract.py", line 260, in run_and_get_output run_tesseract(**kwargs) File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytesseract\pytesseract.py", line 236, in run_tesseract raise TesseractError(proc.returncode, get_errors(error_string)) pytesseract.pytesseract.TesseractError: (3221225477, '')

bozhodimitrov commented 4 years ago

This is tesseract specific error and not pytesseract issue. You should try to call tesseract directly from the terminal and check what is going wrong.