Python 使用pytesseract从图像中提取文本
我想使用Python 使用pytesseract从图像中提取文本,python,Python,我想使用Python从下图中提取文本: 我尝试使用以下代码,但出现错误: import pytesseract from PIL import Image img=Image.open(r'gif file path') pytesseract.pytesseract.tesseract_cmd = 'C:/Program Files (x86)/Tesseract- OCR/tesseract' r=pytesseract.image_to_string(img) print(r) A
Python
从下图中提取文本:
我尝试使用以下代码,但出现错误:
import pytesseract
from PIL import Image
img=Image.open(r'gif file path')
pytesseract.pytesseract.tesseract_cmd = 'C:/Program Files (x86)/Tesseract-
OCR/tesseract'
r=pytesseract.image_to_string(img)
print(r)
And
from PIL import Image
from pytesseract import image_to_string
img=Image.open('gif file path')
text=image_to_string(img)
print(text)
错误:
TesseractNotFoundError
请帮助使用Python
获取文本的任何方法
注意:
pytesseract
已安装。一件事是安装库pytesseract,另一件事是安装Tesseract
如果您使用Linux,请尝试:
sudo apt install libtesseract-dev tesseract-ocr
是否确实已将正确的路径添加到tesseract.exe,pytesseract.pytesseract.tesseract_cmd=r'C:/Program Files(x86)/tesseract-OCR/tesseract.exe。仔细检查路径中是否存在文件,将正确的路径添加到tesseract.exe。