Can .so files be run using Chaquopy?
See original GitHub issuei am trying to call a .so file but it fails.
MainActivity.java:
Python py = Python.getInstance();
PyObject pyf = py.getModule("temp");
temp.py:
from test1 import showimg
showimg(1,2)
I am trying to call test1.so file instead of test1.py but it fails:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.styleapp, PID: 8801
com.chaquo.python.PyException: ELFError: Magic number does not match
at <python>.java._vendor.elftools.common.utils._assert_with_exception(utils.py:101)
at <python>.java._vendor.elftools.common.utils.elf_assert(utils.py:69)
at <python>.java._vendor.elftools.elf.elffile._identify_file(elffile.py:229)
at <python>.java._vendor.elftools.elf.elffile.__init__(elffile.py:61)
at <python>.java.chaquopy.import_override(import.pxi:26)
at <python>.temp.<module>(temp.py:1)
at <python>.importlib._bootstrap._call_with_frames_removed(<frozen importlib._bootstrap>:219)
at <python>.importlib._bootstrap_external.exec_module(<frozen importlib._bootstrap_external>:783)
at <python>.java.android.importer.exec_module(importer.py:503)
at <python>.java.android.importer.exec_module(importer.py:546)
at <python>.importlib._bootstrap._load_unlocked(<frozen importlib._bootstrap>:671)
at <python>.importlib._bootstrap._find_and_load_unlocked(<frozen importlib._bootstrap>:975)
at <python>.importlib._bootstrap._find_and_load(<frozen importlib._bootstrap>:991)
at <python>.importlib._bootstrap._gcd_import(<frozen importlib._bootstrap>:1014)
at <python>.importlib.import_module(__init__.py:127)
at <python>.chaquopy_java.Java_com_chaquo_python_Python_getModule(chaquopy_java.pyx:152)
at com.chaquo.python.Python.getModule(Native Method)
at com.example.styleapp.MainActivity.runthemodel(MainActivity.java:126)
at com.example.styleapp.MainActivity.access$000(MainActivity.java:45)
at com.example.styleapp.MainActivity$2.onMenuItemClick(MainActivity.java:102)
at androidx.appcompat.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:154)
at androidx.appcompat.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:991)
at androidx.appcompat.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:981)
at androidx.appcompat.widget.ActionMenuView.invokeItem(ActionMenuView.java:625)
at androidx.appcompat.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:151)
at android.view.View.performClick(View.java:7140)
at android.view.View.performClickInternal(View.java:7117)
at android.view.View.access$3500(View.java:801)
at android.view.View$PerformClick.run(View.java:27355)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7410)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)
But if i call test1.py, it runs succesfully. Here is my test1.py:
def showimg(i,j):
print(i+j)
Why does it fail? Previously i have been told that Chaquopy doesnt import-and-run .pyc files. Does it not support .so files?
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
FAQ - Chaquopy 13.0
Yes, it can be used with any framework which lets you do the following: Add content to your app's build.gradle files. Call Java...
Read more >Chaquopy How can import .so in python file - Stack Overflow
i put the so file in assets package, and i use the method in the following code to get .so file in python...
Read more >How to use Chaquopy to run Python Code and obtain its ...
In this article, I will explain to you how to easily run Python code and obtain its output using Chaquopy in your Android...
Read more >chaquopy - Dart API docs - Pub.dev
This is an unofficial Chaquopy Flutter plugin to run Python code on Android. ... Then, in the module-level build.gradle file (usually in the...
Read more >Running Python Scripts on the Android Frontend with Chaquopy
0:00 · New! Watch ads now so you can enjoy fewer interruptions. Got it ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes: for more details on the tool, see https://github.com/chaquo/chaquopy/issues/175#issuecomment-778543307. And for instructions on building your own Cython module, see https://github.com/chaquo/build-wheel/issues/10#issuecomment-1128749342.
So the licensed package build tool builds the .so files for Android platform?