python程序:
from PIL import Image import tesserocr imag=Image.open(r"path") print(tesserocr.image_to_text(imag))
会报以下错误:
Traceback (most recent call last):
File "F:/python code/project/key.py", line 5, in <module>print(tesserocr.image_to_text(imag))
File "tesserocr.pyx", line 2401, in tesserocr._tesserocr.image_to_text
RuntimeError: Failed to init API, possibly an invalid tessdata path: F:\python code\project\
解决方案:
将安装Tesseract-OCR的安装目录路径下的 tessdata文件复制,然后粘贴到你的项目所在的文件夹下的scrips目录下即可解决问题