出现错误:致命错误:在 Google Collab 上找不到“longintrepr.h”文件

问题描述 投票:0回答:1

我想使用 Google Collab 将我的 Python 代码转换为 apk。我需要 Pygame 库,因此我在 buildozer.spec 文件的需求部分中写道:

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

我使用的是Python 3.12.2,当我编写命令时:

!buildozer -v android debug

我收到以下错误:

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.

显然找不到文件“logintrepr.h”。我尝试使用命令 !pip install pygame" 安装 Pygame - 这是成功的 - 但下一次尝试我遇到了相同的错误。[text]

如果您想查看整个错误消息,这里有一个 Google Drive 链接:

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

如果你能解决这个问题那就太好了。

python android apk google-colaboratory buildozer
1个回答
0
投票

请原谅我。我不是这方面的专家,但我在 WSL 上遇到了同样的问题。

我尊重 Google Collab 和 WSL 之间存在很大差异,但您可能会在我的发现中找到解决方案。

我是如何修复它的:

我安装了Pygame:

sudo apt-get 更新 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 克隆 https://github.com/pygame/pygame.git cd pygame python3 setup.py -config -auto python3 setup.py install --user

这不起作用,C 文件没有正确集成
所以我尝试了:

python3 setup.py build_ext --inplace

并且成功了!

我认为问题出在你可能安装了 pygame 文件之类的地方,请原谅我,我几乎不知道我自己做了什么。

另外我认为您需要将 SDL2 文件包含到您的要求中?

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

这些是我用过的。

扎克

© www.soinside.com 2019 - 2024. All rights reserved.