[英]AttributeError: module 'pytesseract.pytesseract' has no attribute 'pytesseract'. Did you mean: 'run_tesseract'?
This is the code:这是代码:
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)
This is the error I get:这是我得到的错误:
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'?
I've done almost everything that's recommended here: installing Tesseract-OCR, adding it to the environment variables, pip install, etc...我已经完成了这里推荐的几乎所有事情:安装 Tesseract-OCR,将其添加到环境变量中,pip install 等等......
what am I missing?我错过了什么?
from pytesseract import pytesseract
This import statement means that there is a module named pytesseract.pytesseract
, and as a convenience, you're calling it simply pytesseract
.这个 import 语句意味着有一个名为
pytesseract.pytesseract
的模块,为方便起见,您将其简称为pytesseract
。
pytesseract.pytesseract.tesseract_cmd = '...'
In order for that line of code to work, there would have to be a module named pytesseract.pytesseract.pytesseract
, which seems doubtful.为了使那行代码工作,必须有一个名为
pytesseract.pytesseract.pytesseract
的模块,这似乎值得怀疑。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.