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...
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
.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.