AttributeError: 模块“pytesseract”没有属性“image_to_string”

Phe*_*mia 0 python python-3.x python-tesseract

> 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')))
Run Code Online (Sandbox Code Playgroud)

回溯(最近一次调用):文件“C:\PythonProjects\pytesseract.py”,第 2 行,在 import pytesseract as pya 文件“C:\PythonProjects\pytesseract.py”,第 5 行,在 print(pya.image_to_string( image.open('doggieville.png'))) AttributeError: 模块 'pytesseract' 没有属性 'image_to_string'

为什么会发生???

小智 7

问题是,您必须将 python 文件重命名为其他名称而不是 pytesseract.py 。你的 python 文件与 tesseract inbuilt function 同名。