![](/img/trans.png)
[英]AttributeError: module 'pytesseract' has no attribute 'run_tesseract'
[英]AttributeError: module 'pytesseract.pytesseract' has no attribute 'pytesseract'. Did you mean: 'run_tesseract'?
這是代碼:
from PIL import Image
from pytesseract import pytesseract
pytesseract.pytesseract.tesseract_cmd = 'C:\Program Files (x86)\Tesseract-OCR\tesseract.exe'
im = Image.open(r"screenshot.png")
text = pytesseract.image_to_string(im)
print(text)
這是我得到的錯誤:
Traceback (most recent call last):
File "c:\Users\mark\Documents\Scripts\screenshot.py", line 3, in <module>
pytesseract.pytesseract.tesseract_cmd = 'C:\Program Files (x86)\Tesseract-OCR\tesseract.exe'
AttributeError: module 'pytesseract.pytesseract' has no attribute 'pytesseract'. Did you mean: 'run_tesseract'?
我已經完成了這里推薦的幾乎所有事情:安裝 Tesseract-OCR,將其添加到環境變量中,pip install 等等......
我錯過了什么?
from pytesseract import pytesseract
這個 import 語句意味着有一個名為pytesseract.pytesseract
的模塊,為方便起見,您將其簡稱為pytesseract
。
pytesseract.pytesseract.tesseract_cmd = '...'
為了使那行代碼工作,必須有一個名為pytesseract.pytesseract.pytesseract
的模塊,這似乎值得懷疑。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.