I'm experimenting Pytesseract, and got a problem. I am running Python 3.8.2 with Tesseract 4.0.0 (Also tried with 5.0.0 and 3.0.5, same error) and Pytesseract 0.3.4 (installed with pip) on Windows 10. I can launch tesseract from cmd, as I added the Path variables as intended. The png image is literally a screenshot of a 6.
The code is very simple:
from PIL import Image
import pytesseract
img = Image.open('6.png')
print(pytesseract.image_to_string(img))
And here is the error I got:
Traceback (most recent call last):
File "C:\Documents\TestPytesseract\findNumber.py", line 5, in <module>
print(pytesseract.image_to_string(img))
File "C:\Users\ilita\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pytesseract\pytesseract.py", line 356, in image_to_string
return {
File "C:\Users\ilita\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pytesseract\pytesseract.py", line 359, in <lambda>
Output.STRING: lambda: run_and_get_output(*args),
File "C:\Users\ilita\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pytesseract\pytesseract.py", line 270, in run_and_get_output
run_tesseract(**kwargs)
File "C:\Users\ilita\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pytesseract\pytesseract.py", line 246, in run_tesseract
raise TesseractError(proc.returncode, get_errors(error_string))
pytesseract.pytesseract.TesseractError: (3221225781, '')
Couldn't find anything about this error code. Any help is welcome.
Thank you very much.
You may try to set the tesseract command in your python code
import pytesseract
# Set the path to Tesseract-OCR
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'
Also, make sure if your Windows environment variables are properly set to the path you installed the Tesseract-OCR. For me, the path to Tesseract-OCR is C:\Program Files\Tesseract-OCR\, so the PATH contains
C:\Program Files\Tesseract-OCR\tessdataC:\Program Files\Tesseract-OCRand there should be an another variable TESSDATA_PREFIX in your environment variables, and should be set as
C:\Program Files\Tesseract-OCR\tessdataHopes that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With