我正在尝试将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'
)
我尝试访问pytesseract文件夹,但它运行此错误:
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.6/dist-packages/pytesseract/pytesseract.py'
答案 0 :(得分:2)
使用以下方法解决:
pytesseract.pytesseract.tesseract_cmd = (
r'/usr/bin/tesseract'
)