tesserocr is a simple, Pillow-friendly Python wrapper around the Tesseract-OCR API, built using Cython. It is currently at version 2.10.0 and maintains an active release schedule with several minor and patch updates throughout the year, primarily focusing on Tesseract/Leptonica version upgrades and Python compatibility.
pip install tesserocrVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates basic text recognition from an image using `tesserocr.PyTessBaseAPI` for more control and `tesserocr.image_to_text` for simplicity. It includes a base64-encoded image to make the example self-contained and runnable.
Install Tesseract-OCR on your system. For Debian/Ubuntu: `sudo apt-get install tesseract-ocr tesseract-ocr-eng`. For macOS: `brew install tesseract`. For Windows, use official installers or Chocolatey.
Ensure `.traineddata` files (e.g., `eng.traineddata`) are in a directory Tesseract can find, or explicitly pass `tessdata_dir='/path/to/tessdata'` and `lang='eng'` to `PyTessBaseAPI`.
If building `tesserocr` from source, ensure your Cython version is `<3.0.0`. Rely on pre-built wheels when possible, as they handle this dependency automatically.
Prefer using `pip install tesserocr` which will attempt to download a pre-built wheel. If encountering build errors, check the GitHub releases for supported Python/OS combinations or consult the build instructions for your specific environment.
Install Tesseract-OCR on your operating system. For example, `sudo apt-get install tesseract-ocr` (Linux) or `brew install tesseract` (macOS).
Ensure that the Tesseract language data files are installed and correctly placed. On Linux, this might be `sudo apt-get install tesseract-ocr-eng`. Alternatively, specify the `tessdata_dir` argument when initializing `PyTessBaseAPI` (e.g., `PyTessBaseAPI(lang='eng', tessdata_dir='/path/to/tessdata/')`).
Install the package using pip: `pip install tesserocr`.