You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am getting a opencv error when I am trying to run the app. I am trying to build a tensorflow-based fault detection system on android. So the build is successful however it crashes before the app is run. I am putting the logs below:
logcat:
--------- beginning of main
--------- beginning of kernel
--------- beginning of system
--------- beginning of crash
2023-08-08 10:34:40.678 5267-5267 AndroidRuntime pid-5267 E FATAL EXCEPTION: main
Process: com.chaquo.myapplication, PID: 5267
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.chaquo.myapplication/com.chaquo.myapplication.MainActivity}: com.chaquo.python.PyException: ModuleNotFoundError: No module named 'cv2'
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3782)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3922)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at android.app.ActivityThread.main(ActivityThread.java:8176)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
Caused by: com.chaquo.python.PyException: ModuleNotFoundError: No module named 'cv2'
at <python>.java.chaquopy.import_override(import.pxi:20)
at <python>.java.chaquopy.import_override(import.pxi:60)
at <python>.predictor.<module>(predictor.py:3)
at <python>.java.chaquopy.import_override(import.pxi:60)
at <python>.inference.<module>(inference.py:2)
at <python>.importlib._bootstrap._call_with_frames_removed(<frozen importlib._bootstrap>:241)
at <python>.importlib._bootstrap_external.exec_module(<frozen importlib._bootstrap_external>:883)
at <python>.java.android.importer.exec_module(importer.py:554)
at <python>.importlib._bootstrap._load_unlocked(<frozen importlib._bootstrap>:688)
at <python>.importlib._bootstrap._find_and_load_unlocked(<frozen importlib._bootstrap>:1006)
at <python>.importlib._bootstrap._find_and_load(<frozen importlib._bootstrap>:1027)
at <python>.importlib._bootstrap._gcd_import(<frozen importlib._bootstrap>:1050)
at <python>.importlib.import_module(__init__.py:126)
at <python>.chaquopy_java.Java_com_chaquo_python_Python_getModuleNative(chaquopy_java.pyx:129)
at com.chaquo.python.Python.getModuleNative(Native Method)
at com.chaquo.python.Python.getModule(Python.java:84)
at com.chaquo.myapplication.MainActivity.onCreate(MainActivity.kt:25)
at android.app.Activity.performCreate(Activity.java:8595)
at android.app.Activity.performCreate(Activity.java:8573)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1456)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3764)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3922)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at android.app.ActivityThread.main(ActivityThread.java:8176)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
2023-08-08 10:42:01.497 6384-6384 AndroidRuntime pid-6384 E FATAL EXCEPTION: main
Process: com.chaquo.myapplication, PID: 6384
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.chaquo.myapplication/com.chaquo.myapplication.MainActivity}: com.chaquo.python.PyException: ImportError: OpenCV loader: missing configuration file: ['config.py']. Check OpenCV installation.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3782)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3922)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at android.app.ActivityThread.main(ActivityThread.java:8176)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
Caused by: com.chaquo.python.PyException: ImportError: OpenCV loader: missing configuration file: ['config.py']. Check OpenCV installation.
at <python>.cv2.load_first_config(__init__.py:109)
at <python>.cv2.bootstrap(__init__.py:111)
at <python>.cv2.<module>(__init__.py:181)
at <python>.java.chaquopy.import_override(import.pxi:60)
at <python>.predictor.<module>(predictor.py:3)
at <python>.java.chaquopy.import_override(import.pxi:60)
at <python>.inference.<module>(inference.py:2)
at <python>.importlib._bootstrap._call_with_frames_removed(<frozen importlib._bootstrap>:241)
at <python>.importlib._bootstrap_external.exec_module(<frozen importlib._bootstrap_external>:883)
at <python>.java.android.importer.exec_module(importer.py:554)
at <python>.importlib._bootstrap._load_unlocked(<frozen importlib._bootstrap>:688)
at <python>.importlib._bootstrap._find_and_load_unlocked(<frozen importlib._bootstrap>:1006)
at <python>.importlib._bootstrap._find_and_load(<frozen importlib._bootstrap>:1027)
at <python>.importlib._bootstrap._gcd_import(<frozen importlib._bootstrap>:1050)
at <python>.importlib.import_module(__init__.py:126)
at <python>.chaquopy_java.Java_com_chaquo_python_Python_getModuleNative(chaquopy_java.pyx:129)
at com.chaquo.python.Python.getModuleNative(Native Method)
at com.chaquo.python.Python.getModule(Python.java:84)
at com.chaquo.myapplication.MainActivity.onCreate(MainActivity.kt:25)
at android.app.Activity.performCreate(Activity.java:8595)
at android.app.Activity.performCreate(Activity.java:8573)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1456)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3764)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3922)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at android.app.ActivityThread.main(ActivityThread.java:8176)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
P.S : For some of the native libraries I used .whl files instead of building them myself using chquopy build tools as the build errors associated with the libraries were not coming up by using .whl files for installation instead of using pip with pypi. Can that be cause of the error?
Thank you all for the support!
The text was updated successfully, but these errors were encountered:
Only android and any wheels will work on Android, not manylinux wheels.
I'm not sure how your build completed, since we don't have any OpenCV builds for Python 3.10. But if you change the version to 3.8, you should be able to install all of the packages in your list except for onnxruntime (#216) and safetensors. To do this, simply list the package names, e.g. install "numba".
Apologies if the issue is not well constructed, it's my first issue.
Chaquopy version
14.0.2Relevant parts of your build.gradle file
Describe your issue:
I am getting a opencv error when I am trying to run the app. I am trying to build a tensorflow-based fault detection system on android. So the build is successful however it crashes before the app is run. I am putting the logs below:
logcat:
P.S : For some of the native libraries I used .whl files instead of building them myself using chquopy build tools as the build errors associated with the libraries were not coming up by using .whl files for installation instead of using pip with pypi. Can that be cause of the error?
Thank you all for the support!
The text was updated successfully, but these errors were encountered: