Install & Compatibility
Where this runs
tested against v0.6.11 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.012s · 19MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.7s · import 0.008s · 19MB
17MB installed
● package 17MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
get_display
✓ from bidi import get_display
✗ from bidi.algorithm import get_display
For versions 0.5.0 and later, this imports the newer, Rust-based implementation. The older 'bidi.algorithm' import is for the pure Python implementation and is used for backward compatibility or specific use cases (e.g., Buildozer, older Python versions).
get_display (Python algo)
✓ from bidi.algorithm import get_display
This explicitly imports the pure Python implementation of the algorithm. It is compatible with older versions and can be useful in environments where the Rust-based wheels might cause issues, or when needing the `upper_is_rtl` parameter (though it's ignored by the Rust impl).
This example demonstrates how to use `get_display` to correctly render BiDi text. The function takes a string and returns the layout for display.
from bidi import get_display
# Example Hebrew text (read as: 'Shalom')
HEBREW_TEXT = ''.join([
'ש', # Shin
'ל', # Lamed
'ו', # Vav
'ם' # Final Mem
])
displayed_text = get_display(HEBREW_TEXT)
print(f"Original: {HEBREW_TEXT}")
print(f"Displayed: {displayed_text}")
# Example with mixed LTR/RTL
mixed_text = "Hello שלום World"
displayed_mixed = get_display(mixed_text)
print(f"Original: {mixed_text}")
print(f"Displayed: {displayed_mixed}")
Debug
Known issues
breakingVersion 0.5.0 introduced significant breaking changes, including dropping support for Python versions older than 3.9. The primary import path for `get_display` changed to `from bidi import get_display` (for the Rust-based implementation), and the `upper_is_rtl` parameter was removed from this new implementation.fixEnsure your project uses Python 3.9+ and update import statements. If you require the Python implementation or the `upper_is_rtl` parameter, explicitly import `from bidi.algorithm import get_display` (note: `upper_is_rtl` is ignored by the Rust implementation).
affects: 0.5.0 and later
breakingVersion 0.6.6 removed support for PyPy3.7 and PyPy3.8 due to an upgrade of the underlying `pyo3` library.fixUpgrade to a newer PyPy version (e.g., PyPy3.9+) or use a CPython environment.
affects: 0.6.6 and later
gotchaWhen building `python-bidi` for platforms like Android using tools like Buildozer, issues may arise due to incompatible pre-built binary wheels (`.so` files). This can lead to runtime errors.fixTry forcing `pip` to install from source using `pip install --no-binary python-bidi python-bidi`. Alternatively, consider temporarily downgrading to an older pure-Python version (e.g., `python-bidi==0.4.2`) if source build issues persist.
affects: All versions, especially with PyO3/Rust backend
gotchaWhen integrating `python-bidi` with other text processing libraries like `arabic-reshaper`, incorrect handling of string encoding (especially when reading from or writing to files) can lead to unexpected display issues or `AssertionError: LRI not allowed here`.fixEnsure consistent `utf-8` encoding is used throughout your text processing pipeline, particularly when reading from files (`open(file, 'r', encoding='utf8')`) before passing text to `get_display`.
affects: All versions
deprecatedThe `upper_is_rtl` argument in `get_display` was a debugging feature specific to the pure Python implementation of the algorithm. It is ignored by the default Rust-based implementation (from `bidi import get_display`) in versions 0.5.0 and later.fixAvoid using `upper_is_rtl` with the default `get_display` import. If you need its specific behavior (which is generally for debugging), you must explicitly import and use the pure Python implementation via `from bidi.algorithm import get_display`.
affects: 0.5.0 and later
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'bidi'
The 'python-bidi' library is not installed in your current Python environment, or the environment is not active.
fixpip install python-bidi
AttributeError: module 'bidi' has no attribute 'get_display'
The 'get_display' function is located within the 'bidi.algorithm' submodule, not directly accessible from the top-level 'bidi' package.
fixYou should import 'get_display' directly from the submodule: `from bidi.algorithm import get_display` or access it via `bidi.algorithm.get_display(...)`.
TypeError: expected string, got <type>
The `bidi.algorithm.get_display` function expects its input argument to be a string, but a different data type (e.g., int, list, NoneType) was provided.
fixEnsure the variable passed to `get_display` is a string. Convert it using `str()` if needed: `get_display(str(your_variable))`.
Upgrade
Version history
0.6.11latest on PyPI · released Jun 30, 2026
Audit
Dependencies
No dependency data recorded yet.