問題描述
我使用 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 在啟動時崩潰的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!