我试图在python中运行一个基本的、非常简单的代码。
from PIL import Image
import pytesseract
im = Image.open("sample1.jpg")
text = pytesseract.image_to_string(im, lang = 'eng')
print(text)这就是它的样子,我实际上已经通过安装程序为windows安装了tesseract。我对Python非常陌生,我不知道如何继续下去?
这里的任何指导都会很有帮助。我试过重新启动我的Spyder应用程序,但没有结果。
发布于 2018-09-08 03:45:11
首先,您应该安装二进制:
在Linux上
sudo apt-get update
sudo apt-get install libleptonica-dev tesseract-ocr tesseract-ocr-dev libtesseract-dev python3-pil tesseract-ocr-eng tesseract-ocr-script-latn在Mac上
brew install tesseract在Windows上
从https://github.com/UB-Mannheim/tesseract/wiki下载二进制文件。然后将pytesseract.pytesseract.tesseract_cmd = 'C:\Program Files (x86)\Tesseract-OCR\tesseract.exe'添加到脚本中。
然后,您应该使用pip安装python包:
pip install tesseract
pip install tesseract-ocr参考资料:https://pypi.org/project/pytesseract/ (安装部分)和https://tesseract-ocr.github.io/tessdoc/Installation.html
https://stackoverflow.com/questions/50951955
复制相似问题