Google Colab 上的(2,'Usage: pytesseract [-l lang] input_file')

(2, 'Usage: pytesseract [-l lang] input_file') on Google Colab

我正在尝试 运行 Tesseract 进入 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)

我在正在上传的图像 ('aaa.png') 上尝试了 运行ning,但是 运行 出现了这个错误:

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

从一个几乎相同(仍未解决)post 中搜索,我尝试了以下代码,但仍然无法正常工作:

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

我试图访问 pytesseract 文件夹,但是 运行 出现了这个错误:

PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.6/dist-packages/pytesseract/pytesseract.py'

通过使用解决:

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