Getting error: fatal error: 'longintrepr.h' file not found on Google Collab

206 Views Asked by At

I wanted to convert my Python Code to apk with Google Collab. I need the library Pygame and so I wrote that in the requirements section in the buildozer.spec file:

# (list) Application requirements
# comma separated e.g. requirements = sqlite3,kivy
requirements = python3,kivy,requests,librosa,numpy,moviepy,pygame,pillow

I am using Python 3.12.2 and when I wrote the command:

!buildozer -v android debug

I got the following error:

STDOUT:
/content/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/other_builds/pygame/armeabi-v7a__ndk_target_21/pygame/setup.py:70: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
  import distutils
running build_ext
building 'pygame._sdl2.sdl2' extension
/root/.buildozer/android/platform/android-ndk-r25b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -target armv7a-linux-androideabi21 -fomit-frame-pointer -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb -fPIC -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -target armv7a-linux-androideabi21 -fomit-frame-pointer -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb -fPIC -I/content/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include -DANDROID -I/root/.buildozer/android/platform/android-ndk-r25b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include -I/content/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/myapp/armeabi-v7a/include/python3.1 -fPIC -D_REENTRANT -DSDL2 -I/content/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/bootstrap_builds/sdl2/jni/SDL/include -Isrc_c -I/content/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/other_builds/hostpython3/desktop/hostpython3/Include -I/content/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/other_builds/hostpython3/desktop/hostpython3/native-build -c src_c/_sdl2/sdl2.c -o build/temp.linux-x86_64-3.11/src_c/_sdl2/sdl2.o
src_c/_sdl2/sdl2.c:211:12: fatal error: 'longintrepr.h' file not found
  #include "longintrepr.h"
           ^~~~~~~~~~~~~~~
1 error generated.

So apparently the file "logintrepr.h" is not found. I tried to install Pygame with the command !pip install pygame" -which was a success- but then the next try I got the same error.[text]

If you want to view the whole error message, here is a Google Drive Link:

(https://drive.google.com/file/d/1kKGaEZpVeww9xJRrEgergE7OrMLhLXau/view?usp=sharing)

If you can solve this problem this would be very great.

1

There are 1 best solutions below

3
Zak On

Forgive me. I'm not an expert with this however I came across the same problem with WSL.

I respect there is a big difference between Google Collab and WSL but you might find the solution in my findings.

How I fixed it was:

I installed Pygame:

sudo apt-get update
sudo apt-get install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libfreetype6-dev libportmidi-dev libjpeg-dev python3-setuptools python3-dev python3-numpy
git clone https://github.com/pygame/pygame.git
cd pygame
python3 setup.py -config -auto
python3 setup.py install --user

This didn't work, the C files didn't integrate properly
so I tried:

python3 setup.py build_ext --inplace

and it worked!

I think the problem is where you might have pygame files installed or something, forgive me I barely know what I did myself.

Also I think you need to include the SDL2 files to your requirements?

python3,pygame,jniusm,sdl2,sdl2_image,sdl2_mixer,sdl2_ttf,png,jpeg

These are the ones I used.

Zak