Importing pycardano throws OSError: could not get source code #2704
-
I'm trying to use a module that installs successfully during the build but then fails at the import when the app is started on android. It works great on linux so what is different between android and linux? paths? More precisely I'm trying to use pycardano in my project. I added it to my dependencies in pyproject.toml
but when I run the build on my android device I get
for testing purposes I commented my functions that requires the import and the import itself.. then the app runs. Just uncommenting the import makes it crash. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
There's a lot of differences between Android and a desktop Linux - including, but not limited to, paths. I have no idea what pycardarno is, so very difficult to comment on what exactly is going wrong here, beyond the detail that is already in the message - that something in the cardarno library is trying to access the source code of the module at runtime, and is doing that in a way that isn't compatible with deployment on Android. This might be due to how code is deployed on Android. In a desktop deployment, an installed package is a directory of files on disk; however, on Android, the code is contained in the APK file, which is effectively a zip. When running on Android, a custom loader is used to import code; this works fine for "standard" Python imports, but if cordarno is relying on assumptions about the availability of code on disk that aren't actually guaranteed by Python's import system, then it could be causing problems. A possible workaround is to use Briefcase's ability to extract files at runtime. This is done automatically for resource files like images, but you can force the whole of a source package to be unpacked at runtime using a configuration option in your
to the Android section of your You may need to modify the specifics of this configuration for your purposes. I don't know what file exactly is being requested, what package it is in, or the package structure of pycordano; so a different |
Beta Was this translation helpful? Give feedback.
There's a lot of differences between Android and a desktop Linux - including, but not limited to, paths.
I have no idea what pycardarno is, so very difficult to comment on what exactly is going wrong here, beyond the detail that is already in the message - that something in the cardarno library is trying to access the source code of the module at runtime, and is doing that in a way that isn't compatible with deployment on Android.
This might be due to how code is deployed on Android. In a desktop deployment, an installed package is a directory of files on disk; however, on Android, the code is contained in the APK file, which is effectively a zip. When running on Android, a custom loader …