4

I am trying to run Tesseract into Google Colab:

!sudo apt install tesseract-ocr
!pip install pytesseract

import pytesseract
import shutil
import os
import random
try:
 from PIL import Image
except ImportError:
 import Image

from google.colab import files
uploaded = files.upload()

extractedInformation = pytesseract.image_to_string(Image.open('aaa.png'))
print(extractedInformation)

I tried running on an image ('aaa.png') I am uploading, but it runs this error:

TesseractError: (2, 'Usage: pytesseract [-l lang] input_file')

Searching from an almost identical (still unsolved) post, I tried the following code, but still is not working:

pytesseract.pytesseract.tesseract_cmd = (
    r'/usr/local/bin/tesseract'
)

I tried to access the pytesseract folder, but it runs this error:

enter image description here

PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.6/dist-packages/pytesseract/pytesseract.py'
ardito.bryan
  • 429
  • 9
  • 22

1 Answers1

6

Solved by using:

pytesseract.pytesseract.tesseract_cmd = (
    r'/usr/bin/tesseract'
)
ardito.bryan
  • 429
  • 9
  • 22