#719·RapidOCR

Arabic recognition crashes: python-bidi is required at runtime but is not a declared dependency

Author: al-ashalashCreated Aug 2, 2026Updated Aug 7, 2026

Summary

A fresh pip install rapidocr onnxruntime cannot run Arabic recognition. The first call raises ModuleNotFoundError because python-bidi is imported at runtime but is not declared as a dependency or as an extra.

Any RTL language goes through reorder_bidi_for_display in rapidocr/utils/utils.py, so this affects every user whose first Arabic (or other RTL) call is also their first call.

Environment

  • rapidocr 3.9.2, onnxruntime 1.28.0
  • Python 3.12.10, Windows 10 x64, CPU only
  • Installed with: pip install rapidocr onnxruntime

Reproduction

python
from rapidocr import RapidOCR, LangRec, OCRVersion, ModelType

engine = RapidOCR(params={
    "Rec.lang_type": LangRec.ARABIC,
    "Rec.ocr_version": OCRVersion.PPOCRV5,
    "Rec.model_type": ModelType.MOBILE,
})
engine("any_image_with_arabic_text.png")

Actual

The Arabic model downloads correctly, then recognition fails:

File "...\rapidocr\ch_ppocr_rec\main.py", line 143, in __call__
    txts = reorder_bidi_for_display(txts)
File "...\rapidocr\\\utils\\\utils.py", line 21, in reorder_bidi_for_display
    raise ModuleNotFoundError(
ModuleNotFoundError: Required dependency 'python-bidi' is not installed. Install it with: pip install python-bidi

Expected

Either the dependency is installed with the package, or the failure happens before any model download — not after a 7.65 MB download completes.

The error message itself is good and told me exactly what to do. The problem is only that it happens at all on a documented, supported configuration.

Suggested fix

Any of these would work; listed cheapest first:

  1. Add an extra so the docs can say pip install rapidocr[rtl] (or [arabic]), and mention it in the Arabic guide.
  2. Declare python-bidi as a plain dependency — it is small and pure Python.
  3. Keep it optional but check for it in RapidOCR.__init__ when Rec.lang_type is an RTL language, so the error is raised at construction time rather than after downloading models and running detection.

Option 3 alone would remove the surprise even if you prefer to keep the dependency optional.

Note

Everything else worked well once the package was installed — the Arabic model ran on CPU and returned text in correct logical order on real scanned documents. Thank you for shipping Arabic support in v3.5.0; this is the only packaging snag I hit.

(Edited: corrected the OS version — Windows 10, not 11.)