python-bidi vs buildozer

86 views
Skip to first unread message

Metin Koc

unread,
Jun 25, 2025, 9:26:29 PMJun 25
to Kivy users support
Hello everyone,

I am using python-bidi and arabic-reshaper in my project to use Arabic letters (right to left) however, buildozer always returns an error about python-bidi and I couldn't get any solution for this so far and there is no bidi alternative whatsoever.

I may have a knowledge gap whether only Arabic Reshaper (works without issue) can solve my problem or not but there is no doubt buildozer is not compiling bidi as far as I am concerned.

Hence, I decided to reach out to you guys perhaps someone has an experience to guide me thru on this.

I am looking forward to hearing from you.

Many thanks in advance.

Best,
Metin

Yassine Ouchen

unread,
Jun 26, 2025, 12:41:40 PMJun 26
to kivy-...@googlegroups.com
python-bidi sometimes fails on Android when building with Kivy. A better alternative is pybidi—a faster, Cython-optimized version of the same library How to Fix It: 1. In buildozer.spec, replace: requirements = python-bidi with: requirements = pybidi 2. in your Python code, change: from bidi.algorithm import get_display to: from pybidi.algorithm import get_display

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/kivy-users/CALrVYjYrxzsyrhvZQFB-XRh%3DPa4nK8j9NCg44aNK7xYoG1pkEA%40mail.gmail.com.

Yassine Ouchen

unread,
Jun 26, 2025, 12:44:01 PMJun 26
to kivy-...@googlegroups.com
python-bidi sometimes fails on Android when building with Kivy. A better alternative is pybidi—a faster, Cython-optimized version of the same library 

How to Fix It:

1. In buildozer.spec, 
replace: 
requirements = python-bidi 
with: 
requirements = pybidi 

2. in your Python code, 
change: 
from bidi.algorithm import get_display 
to: 
from pybidi.algorithm import get_display


On Thu, Jun 26, 2025 at 2:26 AM Metin Koc <metin...@gmail.com> wrote:
--

Metin Koc

unread,
Jun 26, 2025, 3:11:57 PMJun 26
to kivy-...@googlegroups.com
Hi Yassin, thank you for your answer.

I did install  PyBidi by using "pip install PyBidi" and put  from pybidi.algorithm import get_display in to main.py but it returns this error;

..............main.py", line 10, in <module>
from pybidi.algorithm import get_display
ModuleNotFoundError: No module named 'pybidi'

Here is the packet list of venv. It seems the requirements are already satisfied. Any ideas? 

Package            Version
------------------ ----------
annotated-types    0.7.0
arabic-reshaper    3.0.0
asyncgui           0.6.3
asynckivy          0.6.4
certifi            2025.4.26
charset-normalizer 3.4.2
docutils           0.21.2
examples           1.0.2
filetype           1.2.0
idna               3.10
Kivy               2.3.1
kivy_deps.angle    0.4.0
kivy_deps.glew     0.3.1
kivy_deps.sdl2     0.8.0
Kivy-examples      2.3.1
Kivy-Garden        0.1.5
KivyGradient       0.0.5
kivymd             2.0.1.dev0
materialyoucolor   2.0.10
pillow             10.4.0
pip                25.1.1
PyBidi             1.0
pydantic           2.11.4
pydantic_core      2.33.2
Pygments           2.19.1
pypiwin32          223
python-bidi        0.6.6
pywin32            310
requests           2.32.3
setuptools         80.9.0
typing_extensions  4.13.2
typing-inspection  0.4.0
urllib3            2.4.0

Thanks,
Metin

Yassine Ouchen

unread,
Jun 26, 2025, 7:59:39 PMJun 26
to Kivy users support

Hi Metin,

There’s no need to switch to pybidi. I tested a simple Kivy app using python-bidi and arabic_reshaper, and it worked perfectly on Android.

✅ What I did in buildozer.spec:

Requirements:

requirements = python3==3.11.11, pillow, kivy, python-bidi, future, arabic_reshaper

🔹 I included future explicitly, because python-bidi depends on it. Not adding it can lead to import errors during the build or at runtime.

Android Configuration:

I also made sure to use a high Android API and SDK version:

# (int) Target Android API 
android.api = 34 

# (int) Minimum API your APK will support 
android.minapi = 21 

# (int) Android SDK version to use 
android.sdk = 34 

# (str) Android NDK version to use 
android.ndk = 25b

After applying this setup, the APK was built successfully and ran without any issues. Arabic text displayed properly using bidi.algorithm.get_display() and arabic_reshaper.reshape().


If you're still running into build errors, feel free to share your Buildozer logs — I'd be happy to help pinpoint the exact issue.

Best regards,
OuchenTech

Metin Koc

unread,
Jun 27, 2025, 7:23:31 PMJun 27
to kivy-...@googlegroups.com
Hi Yassine,

I am so glad from your support and also glad to see that python-bidi is working without any issue in your particular scenario so it doesn't seem desperate anymore.

I made some changes based on your instructions and sharing spec file and traceback for your information. As you will see, it is obviously addressing python-bidi again.
ImportError: dlopen failed: "/data/data/org.myproject.myproject/files/app/_python_bundle/site-packages/bidi/bidi.so" is 64-bit instead of 32-bit
06-27 05:01:40.062 27500 27533 I python  : Python for android ended.

Again, thank you very much for your effort! Really appreciate it

Best,
Metin

traceback.txt
buildozer.spec

Yassine Ouchen

unread,
Jun 28, 2025, 11:59:08 AMJun 28
to Kivy users support

Hi,

The error: 

"dlopen failed: ...bidi.so is for EM_X86_64 instead of EM_AARCH64"

means that python-bidi was installed as a binary (wheel) built for x86_64 (PC), but Android requires ARM64. This happens because Buildozer (via pip) downloaded the .whl instead of the .tar.gz source — and that wheel includes a .so file not compatible with Android.
(I’m not sure why this happens specifically in your case, but it’s a common issue.)  

Here are some potential solutions you can try:  

1. Try forcing pip to install from source

Before the build, run:

pip uninstall python-bidi
pip install --no-binary python-bidi python-bidi

Then clean and rebuild:

buildozer android clean
buildozer android debug

2. Try using the GitHub version

In your buildozer.spec, replace python-bidi with the GitHub source:  

requirements = python3,kivy,git+https://github.com/MeirKriheli/python-bidi.git,future,arabic_reshaper

This tells Buildozer to install directly from the source code, which may avoid the binary issue.

3. Try copying the code directly

- Download the library from GitHub

- Copy the bidi/ folder into your project directory (alongside main.py)  

- Remove python-bidi from the requirements list

- Then import it in your code as usual:

       from bidi.algorithm import get_display


Let me know which one works for you — happy to help further!
— OuchenTech

metin...@gmail.com

unread,
Jun 29, 2025, 6:28:25 AMJun 29
to kivy-...@googlegroups.com

Hello Yassine,

 

I think I found the solution for my case by downgrading python-bidi to python-bidi==0.4.2. I also tried with intermediate versions like 0.5.0 or 0.6.2 but only 0.4.2 worked out.

 

Python;

from bidi.algorithm import get_display

buildozer.spec;

requirements = python3,kivy,git+https://github.com/kivymd/KivyMD.git@master,materialyoucolor,asynckivy,asyncgui,pillow,python-bidi==0.4.2,arabic-reshaper

 

Yes, indeed it’s a known issue. I am not sure whether it worked only for my case but I will share my observations with community as much as I can.

 

Your advices were inspiring. I really appreciate for your valuable support. Thanks very much my friend 😊

 

Best,

Metin

Metin Koc

unread,
Jul 1, 2025, 8:38:28 PMJul 1
to Kivy users support
Hi Yassine,

I am so glad from your support and also glad to see that python-bidi is working without any issue in your particular scenario so it doesn't seem desperate anymore.

I made some changes based on your instructions and sharing spec file and traceback for your information. As you will see, it is obviously addressing python-bidi.

ImportError: dlopen failed: "/data/data/org.myproject.myproject/files/app/_python_bundle/site-packages/bidi/bidi.so" is 64-bit instead of 32-bit
06-27 05:01:40.062 27500 27533 I python  : Python for android ended.

Again, thank you very much for your effort! Really appreciate it
(I sent this mail yesterday but not sure if it delivered properly or not so I am sending one more from group)

Best,
Metin
buildozer.spec
traceback.txt

Yassine Ouchen

unread,
Jul 2, 2025, 5:46:57 AMJul 2
to Kivy users support

Hi Metin,

I'm glad it worked for you! Thanks for sharing the solution with the community.

Quick tip: Be careful when choosing fonts for Arabic text. Some fonts don't display all Arabic letters properly. 

Best, OuchenTech

Reply all
Reply to author
Forward
0 new messages