AttributeError:部分初始化的模块'pytesseract'没有属性'image_to_string'

时间:2020-08-06 14:48:38

标签: python python-3.x python-tesseract

我确实安装了pytesseract并安装了OCR。 完整错误:

Traceback (most recent call last):
  File "c:/Users/Hackry/Documents/pytest/tess.py", line 2, in <module>
    import pytesseract
  File "c:\Users\Hackry\Documents\pytest\pytesseract.py", line 6, in <module>
    text = pytesseract.image_to_string(img)
AttributeError: partially initialized module 'pytesseract' has no attribute 'image_to_string' (most likely due to a circular import)

我的代码

from PIL import Image
import pytesseract
pytesseract.pytesseract.tesseract_cmd = 'C:/Users/Hackry/AppData/Local/Tesseract-OCR/tesseract.exe' #define tesseract path

img = Image.open('C:/Users/Hackry/Documents/pytest/text.jpg')
text = pytesseract.image_to_string(img)

print(text) 

0 个答案:

没有答案