AttributeError: module 'pytesseract' has no attribute 'image_to_string'
1 2 3 4 5 6 | > 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'
号
为什么会这样????
问题是,您必须将python文件重命名为其他文件,而不是pytesseract.py。python文件和tesseract内置函数具有相同的名称。
你能试试这个吗?
1 2 3 4 5 6 | 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'))) |
import语句需要在单独的行中。