kivy / kivy

Open source UI framework written in Python, running on Windows, Linux, macOS, Android and iOS
https://kivy.org
MIT License
17.68k stars 3.07k forks source link

ImportError: no module named cv2 #5141

Closed martirius closed 7 years ago

martirius commented 7 years ago

Versions

Description

I'm trying to write an application for Android using opencv. It works perfectly on Lubuntu and building it with buildozer give me 0 errors. But when i launch the application on android it crash immediately. It says that it doesn't find the module named cv2 but i don't understand why. Above the log captured with logcat

Code and Logs

04-28 21:24:58.467 16578-16578/? I/art: Late-enabling -Xcheck:jni 04-28 21:24:58.531 16578-16591/org.test.myapp E/HAL: load: id=gralloc != hmi->id=gralloc 04-28 21:24:58.576 16578-16578/org.test.myapp I/HwCust: Constructor found for class android.app.HwCustHwWallpaperManagerImpl 04-28 21:24:58.608 16578-16578/org.test.myapp I/HwSecImmHelper: mSecurityInputMethodService is null 04-28 21:24:58.634 16578-16578/org.test.myapp W/linker: /data/app/org.test.myapp-1/lib/arm64/libpython2.7.so: is missing DT_SONAME will use basename as a replacement: "libpython2.7.so" 04-28 21:24:58.642 16578-16578/org.test.myapp W/linker: /data/data/org.test.myapp/files/app/lib/python2.7/lib-dynload/_io.so: is missing DT_SONAME will use basename as a replacement: "_io.so" 04-28 21:24:58.646 16578-16578/org.test.myapp W/linker: /data/data/org.test.myapp/files/app/lib/python2.7/lib-dynload/unicodedata.so: is missing DT_SONAME will use basename as a replacement: "unicodedata.so" 04-28 21:24:58.652 16578-16578/org.test.myapp I/HwSecImmHelper: mSecurityInputMethodService is null 04-28 21:24:58.658 16578-16578/org.test.myapp I/PythonActivity: Surface will NOT be transparent 04-28 21:24:58.672 16578-16607/org.test.myapp E/HAL: load: id=gralloc != hmi->id=gralloc 04-28 21:24:58.672 16578-16607/org.test.myapp I/OpenGLRenderer: Initialized EGL, version 1.4 04-28 21:24:58.705 16578-16621/org.test.myapp I/SDL: SDL_Android_Init() 04-28 21:24:58.705 16578-16621/org.test.myapp I/SDL: SDL_Android_Init() finished! 04-28 21:24:58.705 16578-16621/org.test.myapp I/python: Initialize Python for Android 04-28 21:24:58.705 16578-16621/org.test.myapp I/python: Changing directory to the one provided by ANDROID_ARGUMENT 04-28 21:24:58.705 16578-16621/org.test.myapp I/python: /data/user/0/org.test.myapp/files/app 04-28 21:24:58.705 16578-16621/org.test.myapp I/python: Preparing to initialize python 04-28 21:24:58.705 16578-16621/org.test.myapp I/python: crystax_python does not exist 04-28 21:24:58.710 16578-16621/org.test.myapp I/python: Initialized python 04-28 21:24:58.710 16578-16621/org.test.myapp I/python: AND: Init threads 04-28 21:24:58.712 16578-16621/org.test.myapp I/python: testing python print redirection 04-28 21:24:58.713 16578-16621/org.test.myapp I/python: Setting up python from ANDROID_PRIVATE 04-28 21:24:58.714 16578-16621/org.test.myapp I/python: ('Android path', ['/data/user/0/org.test.myapp/files/app/lib/python27.zip', '/data/user/0/org.test.myapp/files/app/lib/python2.7/', '/data/user/0/org.test.myapp/files/app/lib/python2.7/lib-dynload/', '/data/user/0/org.test.myapp/files/app/lib/python2.7/site-packages/', '/data/user/0/org.test.myapp/files/app']) 04-28 21:24:58.732 16578-16621/org.test.myapp I/python: ('os.environ is', {'ANDROID_APP_PATH': '/data/user/0/org.test.myapp/files/app', 'EXTERNAL_STORAGE': '/sdcard', 'SYSTEMSERVERCLASSPATH': '/system/framework/services.jar:/system/framework/ethernet-service.jar:/system/framework/wifi-service.jar:/system/framework/hwServices.jar:/system/framework/hwWifi-service.jar:/system/framework/hwcustServices.jar:/system/framework/hwcustwifi-service.jar', 'ANDROID_SOCKET_zygote': '12', 'BOOTCLASSPATH': '/system/framework/core-libart.jar:/system/framework/conscrypt.jar:/system/framework/okhttp.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/system/framework/apache-xml.jar:/system/framework/org.apache.http.legacy.boot.jar:/system/framework/hwEmui.jar:/system/framework/hwTelephony-common.jar:/system/framework/hwframework.jar:/system/framework/org.simalliance.openmobileapi.jar:/system/framework/hwaps.jar:/system/framework/hwcustEmui.jar:/system/framework/hwcustTelephony-common.jar:/system/framework/hwcustframework.jar:/system/framework/VireCustomFramework.jar', 'ANDROID_PROPERTY_WORKSPACE': '11,0', 'PATH': '/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin', 'ANDROID_STORAGE': '', 'ANDROID_BOOTLOGO': '1', 'ANDROID_ASSETS': '/system/app', 'CUST_POLICY_DIRS': '/system/emui/base:/system/emui/oversea:/system/emui:/system/global:/system/etc:/hw_oem:/cust/hw/normal:/data/cust:/cust_spec', 'PYTHONOPTIMIZE': '2', 'ANDROID_PRIVATE': '/data/user/0/org.test.myapp/files', 'ANDROID_ENTRYPOINT': 'main.pyo', 'PYTHONPATH': '/data/user/0/org.test.myapp/files/app:/data/user/0/org.test.myapp/files/app/lib', 'ANDROID_DATA': '/data', 'PYTHON_NAME': 'python', 'ANDROID_ROOT': '/system', 'PYTHONHOME': '/data/user/0/org.test.myapp/files/app', 'OEM_ROOT': '/hw_oem', 'ASEC_MOUNTPOINT': '/mnt/asec', 'ANDROID_ARGUMENT': '/data/user/0/org.test.myapp/files/app'}) 04-28 21:24:58.732 16578-16621/org.test.myapp I/python: ('Android kivy bootstrap done. name is', 'main') 04-28 21:24:58.736 16578-16578/org.test.myapp I/HwSecImmHelper: mSecurityInputMethodService is null 04-28 21:24:58.736 16578-16578/org.test.myapp I/HwSecImmHelper: mSecurityInputMethodService is null 04-28 21:24:58.763 16578-16621/org.test.myapp I/python: ['/data/user/0/org.test.myapp/files/app/lib/python2.7/site-packages', '/data/user/0/org.test.myapp/files/app/lib/site-python'] 04-28 21:24:58.763 16578-16621/org.test.myapp I/python: AND: Ran string 04-28 21:24:58.763 16578-16621/org.test.myapp I/python: Run user program, change dir and execute entrypoint 04-28 21:24:58.862 16578-16621/org.test.myapp I/python: [INFO ] [Logger ] Record log in /data/user/0/org.test.myapp/files/app/.kivy/logs/kivy_17-04-28_10.txt 04-28 21:24:58.862 16578-16621/org.test.myapp I/python: [INFO ] [Kivy ] v1.9.2.dev0, git-Unknown, 20170426 04-28 21:24:58.863 16578-16621/org.test.myapp I/python: [INFO ] [Python ] v2.7.2 (default, Apr 25 2017, 23:12:16) 04-28 21:24:58.863 16578-16621/org.test.myapp I/python: [GCC 4.9.x 20150123 (prerelease)] 04-28 21:24:58.871 16578-16621/org.test.myapp W/linker: /data/data/org.test.myapp/files/app/lib/python2.7/site-packages/kivy/_clock.so: is missing DT_SONAME will use basename as a replacement: "_clock.so" 04-28 21:24:58.881 16578-16621/org.test.myapp W/linker: /data/data/org.test.myapp/files/app/lib/python2.7/site-packages/kivy/_event.so: is missing DT_SONAME will use basename as a replacement: "_event.so" 04-28 21:24:58.884 16578-16621/org.test.myapp W/linker: /data/data/org.test.myapp/files/app/lib/python2.7/site-packages/kivy/properties.so: is missing DT_SONAME will use basename as a replacement: "properties.so" 04-28 21:24:58.891 16578-16621/org.test.myapp I/python: [INFO ] [Factory ] 194 symbols loaded

                                                    [ 04-28 21:24:59.147  2922: 2922 E/         ]
                                                    process stopped due to unexpected signal 13

04-28 21:24:59.260 16578-16621/org.test.myapp W/linker: /data/data/org.test.myapp/files/app/lib/python2.7/site-packages/kivy/graphics/instructions.so: is missing DT_SONAME will use basename as a replacement: "instructions.so" 04-28 21:24:59.263 16578-16621/org.test.myapp W/linker: /data/data/org.test.myapp/files/app/lib/python2.7/site-packages/kivy/graphics/buffer.so: is missing DT_SONAME will use basename as a replacement: "buffer.so" 04-28 21:24:59.266 16578-16621/org.test.myapp W/linker: /data/data/org.test.myapp/files/app/lib/python2.7/site-packages/kivy/graphics/vertex.so: is missing DT_SONAME will use basename as a replacement: "vertex.so" 04-28 21:24:59.269 16578-16621/org.test.myapp W/linker: /data/data/org.test.myapp/files/app/lib/python2.7/site-packages/kivy/graphics/cgl.so: is missing DT_SONAME will use basename as a replacement: "cgl.so" 04-28 21:24:59.272 16578-16621/org.test.myapp W/linker: /data/data/org.test.myapp/files/app/lib/python2.7/site-packages/kivy/graphics/vbo.so: is missing DT_SONAME will use basename as a replacement: "vbo.so" 04-28 21:24:59.275 16578-16621/org.test.myapp W/linker: /data/data/org.test.myapp/files/app/lib/python2.7/site-packages/kivy/graphics/compiler.so: is missing DT_SONAME will use basename as a replacement: "compiler.so" 04-28 21:24:59.278 16578-16621/org.test.myapp W/linker: /data/data/org.test.myapp/files/app/lib/python2.7/site-packages/kivy/graphics/transformation.so: is missing DT_SONAME will use basename as a replacement: "transformation.so" 04-28 21:24:59.281 16578-16621/org.test.myapp W/linker: /data/data/org.test.myapp/files/app/lib/python2.7/site-packages/kivy/graphics/shader.so: is missing DT_SONAME will use basename as a replacement: "shader.so" 04-28 21:24:59.284 16578-16621/org.test.myapp W/linker: /data/data/org.test.myapp/files/app/lib/python2.7/site-packages/kivy/graphics/texture.so: is missing DT_SONAME will use basename as a replacement: "texture.so" 04-28 21:24:59.289 16578-16621/org.test.myapp W/linker: /data/data/org.test.myapp/files/app/lib/python2.7/site-packages/kivy/graphics/context_instructions.so: is missing DT_SONAME will use basename as a replacement: "context_instructions.so" 04-28 21:24:59.319 16578-16621/org.test.myapp W/linker: /data/data/org.test.myapp/files/app/lib/python2.7/site-packages/kivy/core/image/_img_sdl2.so: is missing DT_SONAME will use basename as a replacement: "_img_sdl2.so" 04-28 21:24:59.324 16578-16621/org.test.myapp I/python: [INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_gif (img_pil, img_ffpyplayer ignored) 04-28 21:24:59.327 16578-16621/org.test.myapp W/linker: /data/data/org.test.myapp/files/app/lib/python2.7/site-packages/kivy/graphics/fbo.so: is missing DT_SONAME will use basename as a replacement: "fbo.so" 04-28 21:24:59.331 16578-16621/org.test.myapp W/linker: /data/data/org.test.myapp/files/app/lib/python2.7/site-packages/kivy/graphics/context.so: is missing DT_SONAME will use basename as a replacement: "context.so" 04-28 21:24:59.335 16578-16621/org.test.myapp W/linker: /data/data/org.test.myapp/files/app/lib/python2.7/site-packages/kivy/graphics/opengl.so: is missing DT_SONAME will use basename as a replacement: "opengl.so" 04-28 21:24:59.341 16578-16621/org.test.myapp W/linker: /data/data/org.test.myapp/files/app/lib/python2.7/site-packages/kivy/graphics/opengl_utils.so: is missing DT_SONAME will use basename as a replacement: "opengl_utils.so" 04-28 21:24:59.348 16578-16621/org.test.myapp W/linker: /data/data/org.test.myapp/files/app/lib/python2.7/site-packages/kivy/graphics/vertex_instructions.so: is missing DT_SONAME will use basename as a replacement: "vertex_instructions.so" 04-28 21:24:59.352 16578-16621/org.test.myapp W/linker: /data/data/org.test.myapp/files/app/lib/python2.7/site-packages/kivy/graphics/stencil_instructions.so: is missing DT_SONAME will use basename as a replacement: "stencil_instructions.so" 04-28 21:24:59.355 16578-16621/org.test.myapp W/linker: /data/data/org.test.myapp/files/app/lib/python2.7/site-packages/kivy/graphics/gl_instructions.so: is missing DT_SONAME will use basename as a replacement: "gl_instructions.so" 04-28 21:24:59.360 16578-16621/org.test.myapp W/linker: /data/data/org.test.myapp/files/app/lib/python2.7/site-packages/kivy/graphics/scissor_instructions.so: is missing DT_SONAME will use basename as a replacement: "scissor_instructions.so" 04-28 21:24:59.364 16578-16621/org.test.myapp W/linker: /data/data/org.test.myapp/files/app/lib/python2.7/site-packages/kivy/weakproxy.so: is missing DT_SONAME will use basename as a replacement: "weakproxy.so" 04-28 21:24:59.381 16578-16621/org.test.myapp I/python: Traceback (most recent call last): 04-28 21:24:59.382 16578-16621/org.test.myapp I/python: File "/media/kivy/disk2/KivyProject/.buildozer/android/app/main.py", line 10, in 04-28 21:24:59.382 16578-16621/org.test.myapp I/python: ImportError: No module named cv2 04-28 21:24:59.424 16578-16621/org.test.myapp I/python: Python for android ended. 04-28 21:24:59.469 16578-16578/org.test.myapp I/art: System.exit called, status: 0 04-28 21:24:59.469 16578-16578/org.test.myapp I/AndroidRuntime: VM exiting with result code 0, cleanup skipped.

KeyWeeUsr commented 7 years ago

This kind of issues has its appropriate place, in the repository where the building tool resides, therefore here it's either kivy/python-for-android or kivy/buildozer and not in kivy/kivy directly (you can even see from the logs that Kivy started). Anyway, the error log says this:

04-28 21:24:59.381 16578-16621/org.test.myapp I/python: Traceback (most recent call last):
04-28 21:24:59.382 16578-16621/org.test.myapp I/python: File "/media/kivy/disk2/KivyProject/.buildozer/android/app/main.py", line 10, in
04-28 21:24:59.382 16578-16621/org.test.myapp I/python: ImportError: No module named cv2
04-28 21:24:59.424 16578-16621/org.test.myapp I/python: Python for android ended.

that basically means you haven't included (open)cv2 in the requirements when packaging your application, thus it crashes with an ImportError.

Also, please try even the IRC channel and mailing list when you encounter such an issue :)