Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No module named 'pygame._freetype' when Python for android #3265

Open
ArrowLiu234 opened this issue Dec 15, 2024 · 2 comments
Open

No module named 'pygame._freetype' when Python for android #3265

ArrowLiu234 opened this issue Dec 15, 2024 · 2 comments
Labels

Comments

@ArrowLiu234
Copy link

ArrowLiu234 commented Dec 15, 2024

I wrote the following code. It works in my windows with python 3.11.
It also worked when i use "python for android" to compile the android apk.
But the apk is failed when i run the apk after install the apk.
I tried many times, all failed, hope for you help and support. Thanks!!!

The error msgs are as following:

--------------
12-15 14:15:08.131 26124 14916 I python  :   File "/home/liuxiaoming/txtreader/.buildozer/android/app/Render.py", line 2, in <module>
12-15 14:15:08.131 26124 14916 I python  :   File "/home/liuxiaoming/txtreader/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/txtreader/arm64-v8a/pygame/freetype.py", line 3, in <module>
12-15 14:15:08.131   888 22230 I netd    : interfaceSetEnableIPv6(wlan1, true) <0.17ms>
12-15 14:15:08.131 26124 14916 I python  : ModuleNotFoundError: No module named 'pygame._freetype'
12-15 14:15:08.131 26124 14916 I python  : Python for android ended.
--------------

I have checked my buildozer.spec, all the requirements are there, including the pygame-ce:

--------------
requirements = python3==3.10.12, kivy==2.3.0, hostpython3==3.10.12, pyjnius==1.5.0, 
pygame==2.6.1, pygame-ce==2.5.2, chardet, jieba, zhconv, bs4, ebooklib
--------------

And my python code are as following, seems no problem.

--------------
import pygame as pg
from pygame import freetype as ft # [[[trigger the problem]]]
# import pygame.freetype as ft
...
ft.Font(self.cfg.font_name, size=self.fonts_size[i], ) for i in range(len(self.fonts_size))
...
--------------

I also checked the freetype.pc, line 3 is import the Font.

--------------
from pygame._freetype import (

    Font,
    ...
--------------
@COUR4G3
Copy link

COUR4G3 commented Dec 19, 2024

I happened to be looking into this the other day and found the line for freetype is commented out in the Android build configuration, I haven't had a chance to uncomment it, build and check if this resolves the issue or not but thought it'd be helpful to share:

#_freetype src_c/freetype/ft_cache.c src_c/freetype/ft_wrap.c src_c/freetype/ft_render.c src_c/freetype/ft_render_cb.c src_c/freetype/ft_layout.c src_c/freetype/ft_unicode.c src_c/_freetype.c $(SDL) $(FREETYPE) $(DEBUG)

@Starbuck5
Copy link
Member

The path of least resistance here might be to port your code over to using pygame.Font ?

I don't know much about android support, and I don't even know where I would start to get more knowledge about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants