[英]Getting an import error on android while code works on windows (kivy)
I'm building an app using kivy/python.我正在使用 kivy/python 构建一个应用程序。 I created an apk using buildozer.
我使用 buildozer 创建了一个 apk。 On windows my code runs perfectly but when I run the apk on my android device it immediately crashes.
在 Windows 上,我的代码运行完美,但是当我在我的 android 设备上运行 apk 时,它立即崩溃。 I ran
adb logcat
to find the error and I think I've found the relevant bit:我运行
adb logcat
来查找错误,我想我已经找到了相关的位:
I python : Traceback (most recent call last):
I python : File "/home/casper/Desktop/MyApp/.buildozer/android/app/main.py", line 17, in <module>
I python : File "/home/casper/Desktop/MyApp/.buildozer/android/app/price.py", line 8, in <module>
I python : ModuleNotFoundError: No module named 'requests'
I python : Python for android ended.
This seems weird to me because everything works when I run it on my laptop.这对我来说似乎很奇怪,因为当我在笔记本电脑上运行它时一切正常。 Do I need to install
requests
in another directory or something?我是否需要在另一个目录或其他目录中安装
requests
? Thanks!谢谢!
yes your code will work perfectly fine while testing on your windows, this is because python has the module 'requests' .是的,在 Windows 上测试时,您的代码可以正常工作,这是因为 python 具有模块 'requests' 。 But on compiling to apk , you will run into errors because python for android does not have the 'requests' module.
但是在编译为 apk 时,您会遇到错误,因为 android 的 python 没有“请求”模块。 .you will need to check alternative libraries that are supported by 'python for android'
.您需要检查“python for android”支持的替代库
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.