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. The file paths are correct because if I change them I get another error saying that the file cannot be found.
My code:
from PIL import Image
import pytesseract
pytesseract.pytesseract.tesseract_cmd= r'C:\Users\bbrown2\AppData\Local\
Programs\Python\Python37\Scripts\pytesseract'
img = r'C:\Users\bbrown2\Desktop\test.png'
print(pytesseract.image_to_string(Image.open(img)))
I expect it to print out the words in the image but instead I always get this:
Traceback (most recent call last):
File
"c:\Users\bbrown2\Desktop\PythonMaterials\python_test_tesseract.py", line
14, in <module>
print(pytesseract.image_to_string(Image.open(image)))
File "C:\Users\bbrown2\AppData\Local\Programs\Python\Python37\lib\site-
packages\pytesseract\pytesseract.py", line 309, in image_to_string
}[output_type]()
File "C:\Users\bbrown2\AppData\Local\Programs\Python\Python37\lib\site-
packages\pytesseract\pytesseract.py", line 308, in <lambda>
Output.STRING: lambda: run_and_get_output(*args),
File "C:\Users\bbrown2\AppData\Local\Programs\Python\Python37\lib\site-
packages\pytesseract\pytesseract.py", line 218, in run_and_get_output
run_tesseract(**kwargs)
File "C:\Users\bbrown2\AppData\Local\Programs\Python\Python37\lib\site-
packages\pytesseract\pytesseract.py", line 194, in run_tesseract
raise TesseractError(status_code, get_errors(error_string))
pytesseract.pytesseract.TesseractError: (2, 'Usage: python pytesseract.py
[-l lang] input_file')