chaquo / chaquopy

Chaquopy: the Python SDK for Android
https://chaquo.com/chaquopy/
MIT License
749 stars 128 forks source link

FileNotFoundError: Can't open orphan path #1052

Closed idbeny closed 6 months ago

idbeny commented 6 months ago

Chaquopy version

14.0.2

Devices or emulators where the issue happens

Both Devices and emulators

Relevant parts of your code

Show error when launched app. And the location is at on create of MainActivity.java:

py.getModule("runpy").callAttr(
            "run_module",
            getString(R.string.main_module),
            new Kwarg("run_name", "__main__"),
            new Kwarg("alter_sys", true)
        );

Step into when debuging:

image

Describe your issue

Process: com.menusifu.mspyshell.mspyshell, PID: 10839
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.menusifu.mspyshell.mspyshell/org.beeware.android.MainActivity}: com.chaquo.python.PyException: FileNotFoundError: Can't open orphan path 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6669)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: com.chaquo.python.PyException: FileNotFoundError: Can't open orphan path
    at <python>.importlib_resources._adapters.open(_adapters.py:139)
    at <python>.importlib_resources.abc.read_bytes(abc.py:79)
    at <python>.importlib_resources._common._tempfile(_common.py:132)
    at <python>.contextlib.__enter__(contextlib.py:119)
    at <python>.contextlib.enter_context(contextlib.py:448)
    at <python>.escpos.capabilities.<module>(capabilities.py:30)
    at <python>.java.chaquopy.import_override(import.pxi:26)
    at <python>.escpos.escpos.<module>(escpos.py:24)
    at <python>.java.chaquopy.import_override(import.pxi:26)
    at <python>.escpos.printer.cups.<module>(cups.py:16)
    at <python>.java.chaquopy.import_override(import.pxi:26)
    at <python>.escpos.printer.<module>(__init__.py:4)
    at <python>.java.chaquopy.import_override(import.pxi:26)
    at <python>.mspyshell.services.printer.<module>(printer.py:5)
    at <python>.java.chaquopy.import_override(import.pxi:26)
    at <python>.mspyshell.services.<module>(__init__.py:1)
    at <python>.java.chaquopy.import_override(import.pxi:26)
    at <python>.mspyshell.app.<module>(app.py:12)
    at <python>.java.chaquopy.import_override(import.pxi:26)
    at <python>.__main__.<module>(__main__.py:1)
    at <python>.runpy._run_code(runpy.py:87)
    at <python>.runpy._run_module_code(runpy.py:97)
    at <python>.runpy.run_module(runpy.py:225)
    at <python>.chaquopy_java.call(chaquopy_java.pyx:354)
    at <python>.chaquopy_java.Java_com_chaquo_python_PyObject_callAttrThrowsNative(chaquopy_java.pyx:326)
    at com.chaquo.python.PyObject.callAttrThrowsNative(Native Method)
    at com.chaquo.python.PyObject.callAttrThrows(PyObject.java:232)
    at com.chaquo.python.PyObject.callAttr(PyObject.java:221)
    at org.beeware.android.MainActivity.onCreate(MainActivity.java:85)
    at android.app.Activity.performCreate(Activity.java:7136)
    at android.app.Activity.performCreate(Activity.java:7127)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048) 
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) 
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808) 
    at android.os.Handler.dispatchMessage(Handler.java:106) 
    at android.os.Looper.loop(Looper.java:193) 
    at android.app.ActivityThread.main(ActivityThread.java:6669) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 
idbeny commented 6 months ago

I found the reason for the error. It's because python-escpos is used, but there is no problem on other platforms(iOS, macOS, Win). Is there any way to use python-escpos on andorid?

mhsmith commented 6 months ago

This looks like the same problem as #977. The fix is in Chaquopy 15.0.1, which will be released in the next few days.