Python (2,';用法:Google Colab上的pytesseract[-l lang]输入文件';)

Python (2,';用法:Google Colab上的pytesseract[-l lang]输入文件';),python,google-colaboratory,python-tesseract,Python,Google Colaboratory,Python Tesseract,我正在尝试将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

我正在尝试将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')上运行,但它运行以下错误:

TesseractError: (2, 'Usage: pytesseract [-l lang] input_file')
在一篇几乎相同(仍未解决)的帖子中搜索时,我尝试了以下代码,但仍然不起作用:

pytesseract.pytesseract.tesseract_cmd = (
    r'/usr/local/bin/tesseract'
)
我试图访问PyteSeract文件夹,但它运行以下错误:

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

通过以下方式解决:

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

你错过了
pytesseract.image\u to_string
前面的
str
你是说pytesseract.image\u to_string(str…?我在谷歌上搜索过,但每个代码都有我使用过的同一行没有。试试
str(pytesseract.image\u to_string(image.open('aaa.png'))
不幸的是,同样的问题,我也尝试在没有命令行的情况下运行_cmd,同样的问题你肯定需要这个命令-你把这个命令保存在哪里了?如果你在Mac上,它通常在
r'/usr/local/cillar/tesseract/你的tesseract verison/bin/tesseract'下。