导入外部库时 Kivy 在启动时崩溃

Kivy crashes on launch when importing external libraries(导入外部库时 Kivy 在启动时崩溃)
本文介绍了导入外部库时 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 在启动时崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)