AttributeError:模块“pytesseract”没有“image”to“u string”属性

2024-05-14 00:56:35 发布

您现在位置:Python中文网/ 问答频道 /正文

> import image 
> import pytesseract as pya
> 
> pya.tesseract_cmd = r'C:\Users\Euphz\Documents\Artworks\PSD\Speaking
of Dogs\201710'
> print(pya.image_to_string(image.open('doggieville.png')))

Traceback (most recent call last): File "C:\PythonProjects\pytesseract.py", line 2, in import pytesseract as pya File "C:\PythonProjects\pytesseract.py", line 5, in print(pya.image_to_string(image.open('doggieville.png'))) AttributeError: module 'pytesseract' has no attribute 'image_to_string'

为什么会这样???在


Tags: topyimageimportstringpngasline
2条回答

你能试试这个吗?在

import image 
import pytesseract as pya

pya.tesseract_cmd = r'C:\Users\Euphz\Documents\Artworks\PSD\Speaking
of Dogs\201710'
print(pya.image_to_string(image.open('doggieville.png')))

导入语句需要在单独的行中。在

问题是,您必须将python文件重命名为其他文件pytesseract.py. python文件和tesseract内置函数具有相同的名称。在

相关问题 更多 >