导入外部库时 Kivy 在启动时崩溃 [英] Kivy crashes on launch when importing external libraries

查看:23
本文介绍了导入外部库时 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 在启动时崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆