名称错误: python中的图像到文本错误

您所在的位置:网站首页 python代码错误有哪些 名称错误: python中的图像到文本错误

名称错误: python中的图像到文本错误

2023-07-03 22:20| 来源: 网络整理| 查看: 265

我正在开发代码,将图像转换为文本使用以下代码。在执行代码时,我看到了下面的错误。我真的不明白是什么导致了这个问题。有人能帮我找出问题所在吗?

from PIL import Image import PIL.Image from pytesseract import image_to_string import pytesseract img = Image.open('C:\\Users\\Documents\\convert_image_to_text\\Sample.png') pytesseract.pytesseract.tesseract_cmd = 'C:\AppData\Local\Tesseract-OCR\tesseract.exe' text = pytesseract.image_to_string('C:\\Users\\Documents\\convert_image_to_text\\Sample.png') print(text)

以下是错误:

File "C:/Users/Documents/convert_image_to_text/program_to_convert_image_to_text.py", line 21, in text=image_to_string(img) NameError: name 'img' is not defined


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3