Skip to main content

ocrlocal

PyPI version Python versions License: MIT Offline

Dead-simple offline OCR for developers. Point it at an image. Get text. No cloud. No API keys.

ocrlocal wraps Tesseract via pytesseract + Pillow into a polished CLI with batching, JSON output, and a delightful doctor check.


Install

pip install ocrlocal

You also need the Tesseract binary on your system:

Platform Command
Debian / Ubuntu sudo apt update && sudo apt install -y tesseract-ocr
macOS brew install tesseract
Windows (Chocolatey) choco install tesseract
Windows (installer) UB Mannheim builds

Verify everything in one shot:

ocrlocal doctor

60-second demo

# Single image → stdout
ocrlocal receipt.png

# Language pass-through (Tesseract style)
ocrlocal scan.png --lang eng+fra

# Batch + JSON for scripts
ocrlocal photos/*.png --json

# Write .txt files into a folder
ocrlocal invoices/*.jpg --out ./text

Sample JSON:

[
  {
    "file": "receipt.png",
    "text": "TOTAL 12.50",
    "lang": "eng",
    "engine": "tesseract"
  }
]

ocrlocal doctor

A green/red health check for your local OCR stack:

ocrlocal doctor
═══════════════

  ✓  ocrlocal           v0.1.0
  ✓  tesseract binary   /usr/bin/tesseract — tesseract 5.3.0
  ✓  pytesseract        v0.3.13
  ✓  Pillow             v10.4.0

All checks passed. Ready for offline OCR.

If Tesseract is missing, doctor exits with code 2 and points you at apt / brew / choco / the Windows installer.


Features

Feature Details
Offline-only Never phones home. No network calls.
Single or batch Files and shell globs
--json Machine-friendly {file, text, lang, engine} list
--lang Full Tesseract lang strings (eng, eng+fra, …)
--out DIR Write mirrored .txt files
Exit codes 0 ok · 1 OCR/file errors · 2 missing Tesseract/config
-q / -V Quiet mode · version
doctor Binary + library diagnostics

vs calling pytesseract yourself

Raw pytesseract ocrlocal
CLI DIY Ready
Batch / globs DIY Built-in
JSON for scripts DIY --json
Missing-binary UX Cryptic Install hints + exit 2
Health check None ocrlocal doctor
Output files DIY --out DIR

Use the library if you are embedding OCR deep in an app. Use ocrlocal when you want a dependable terminal tool.


CLI reference

ocrlocal [OPTIONS] [IMAGES]...
ocrlocal doctor
Option Meaning
--lang / -l Tesseract languages (default: eng)
--json JSON array on stdout
--out DIR Write .txt files into DIR
-q / --quiet Errors only
-V / --version Print version

Exit codes

  • 0 — success
  • 1 — one or more OCR / file errors (partial batch still reports successes)
  • 2 — missing Tesseract or broken config

Troubleshooting

Symptom Fix
Tesseract OCR was not found Install the system binary (table above), then ocrlocal doctor
Wrong / empty text Try a sharper crop; set --lang to match the document
Not a supported image file Pass a real PNG/JPEG/TIFF/WebP — not a PDF or text file
Language data missing Install packs, e.g. tesseract-ocr-fra on Debian
Integration tests skipped Expected without Tesseract; mocked suite still covers behavior

Development

git clone https://github.com/AshSgDe29071999/ocrlocal.git
cd ocrlocal
pip install -e ".[dev]"
pytest

Integration tests that hit a real Tesseract binary are skipped automatically when tesseract is not on PATH.


License

MIT © AshSgDe29071999

Release files for ocrlocal 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ocrlocal 0.1.1
File Size Uploaded
ocrlocal-0.1.1.tar.gz 11.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ocrlocal 0.1.1
File Interpreter ABI Platform
ocrlocal-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 21.7 kB

Release files / ocrlocal-0.1.1.tar.gz

Download URL ocrlocal-0.1.1.tar.gz
Size 11.4 kB
Tags Source
SHA-256 checksum
How to use checksums
996235fc52f3763685303f8efcad4a6de60369056d8b986608d5044120aba2bd
BLAKE2b-256 checksum
How to use checksums
0f28df693f11c12d14a290031f0cfa6ae31a7bbc11626fe0bdab6ada1014cb0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.

Transparency log

Release files / ocrlocal-0.1.1-py3-none-any.whl

Download URL ocrlocal-0.1.1-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a688c0bc1c41012d2b13cc6881532f9e3d294a14fce54a88ae0f763469efe5cd
BLAKE2b-256 checksum
How to use checksums
313bf768e3cb4f5a8849138d1d533a38b9c157059b280d9b31fbf4ccd17140a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page