I am getting TesseractError: (2, 'Usage: pytesseract [-l lang] input_file') error while converting image to text in google colab

Viewed 1704

below is my code

im=Image.open("/root/ppm_to_jpg/6e196d3b-adec-45ab-b036-5833f96f1bc0-2.jpg")
pytesseract.pytesseract.tesseract_cmd = r'/usr/local/bin/pytesseract'
text=pytesseract.image_to_string(im,lang="eng")
print (text)

I am getting erro as TesseractError: (2, 'Usage: pytesseract [-l lang] input_file') even i have set up the pytesseract.pytesseract.tesseract_cmd = r'/usr/local/bin/pytesseract

can anyone please suggest me what should i do

1 Answers

!sudo apt install tesseract-ocr

The above installs the required dependencies for pytesseract. This is very important, especially the ! without which you cannot install directly to the underlying operating system.

!pip install pytesseract

This installs the Python binding.

Hope this helps.

Related