Kivy crashes on launch when importing external libraries(导入外部库时 Kivy 在启动时崩溃)
问题描述
我使用 Kivy Launcher 运行了一个基本的Hello World".程序,它运行良好,但是当我在开始时添加 import cv2 时,应用程序在启动后立即崩溃.
I used the Kivy Launcher to run a basic "Hello World" program and it worked fine, but when I added in an import cv2 at the beginning, the app crashes immediately after launching.
主.py:Main.py 代码
Android.txt:Android.txt 图片
Android.txt: Image of Android.txt
谢谢!
推荐答案
kivy启动器用于严格运行Kivy模块和Python预装模块.所以在这种情况下,由于 cv2 没有预装在正常的 python 安装中,kivy 启动器无法识别它,然后得到一个ModuleNotFoundError: No Module named cv2"错误,这会导致它崩溃.因此,如果您尝试导入预装 python 的模块以外的模块,则必须使用 Buildozer 编译成 .apk 文件才能在 android 上运行它
The kivy launcher is used to run strictly Kivy modules and Python preinstalled modules. So in this case, since cv2 doesn't come preinstalled in normal python installations, kivy launcher doesn't recognise it and then gets a "ModuleNotFoundError: No Module named cv2" error, which causes it to crash. So, if you're trying to import modules aside from those which come preinstalled with python you'd have to compile into a .apk file using Buildozer to run it on an android
这篇关于导入外部库时 Kivy 在启动时崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:导入外部库时 Kivy 在启动时崩溃


基础教程推荐
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01