from PIL import Image import pytesseract pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe' text = pytesseract.image_to_string(Image.open('sample.png')) print(text) 5. Testing your installation Run this in terminal/command prompt:
pip install pytesseract pillow Then in Python: tesseract ocr download
tesseract --list-langs # shows installed languages Basic OCR test: from PIL import Image import pytesseract pytesseract
tesseract --version If you want to call Tesseract from Python, you still need the Tesseract binary installed as above, then: tesseract ocr download
tesseract --version Using Homebrew (recommended):
Here’s a clear, step-by-step guide to downloading and installing Tesseract OCR on the most common operating systems. The official installer is maintained by UB Mannheim.
brew install tesseract For specific languages: