Skip to content Skip to sidebar Skip to footer

Pytesseract.tesseracterror 'usage: Python Pytesseract.py [-l Lang] Input_file

I am getting the following error when trying to print a simple test image to text. I've verified that I have Pillow (PIL 1.1.7) and tried uninstalling and reinstalling pytesseract.

Solution 1:

The problem is pytesseract is just a nice Python wrapper for the command line program Tesseract. You're supposed to point tesseract_cmd at the actual Tesseract binary, not the pytesseract CLI util.

So, you'll need to install Tesseract. Windows builds are available. I chose the version 3.05 installer, and it installed by default to C:\Program Files (x86)\Tesseract-OCR\tesseract. Then, I ran the following and it worked fine:

from PIL import Image
import pytesseract

pytesseract.pytesseract.tesseract_cmd = (
    r"C:\Program Files (x86)\Tesseract-OCR\tesseract"
)

img = r"C:\Users\cody\Desktop\ocrtest.png"print(pytesseract.image_to_string(Image.open(img)))

Test input:

enter image description here Result:

The (quick) [brown] {fox} jumps!
Over the $43,456.78 <lazy> #90 dog
& duck/goose, as 12.5% of E-mail
from aspammer@website.com is spam.
Der ,,schnelle” braune Fuchs springt
fiber den faulen Hund. Le renard brun
«rapide» saute par-dessus le chien
paresseux. La volpe marrone rapida
salta sopra i] cane pigro. El zorro
marrén répido salta sobre el perro
perezoso. A raposa marrom répida
salta sobre 0 C50 preguicoso.

Post a Comment for "Pytesseract.tesseracterror 'usage: Python Pytesseract.py [-l Lang] Input_file"