Closed 1MochaChan1 closed 3 years ago
Unclear why that occurs. Symbol PyFile_FromFd
exists the lib/libpython3.X
libraries for all 4 Python 3.6, 3.7, 3.8 and 3.9 (on macOS). Perhaps the kivy/python build on Android does not have that symbol.
Is that the only missing symbol? Does python-vlc.py
work fine on the target platform O/S? If so, type python vlc.py --version
in a shell or command window.
Unclear why that occurs. Symbol
PyFile_FromFd
exists thelib/libpython3.X
libraries for all 4 Python 3.6, 3.7, 3.8 and 3.9 (on macOS). Perhaps the kivy/python build on Android does not have that symbol.
I am running this on Ubuntu 20.04.2 LTS I am not sure if that'll cause any problems though.
Is that the only missing symbol? Does
python-vlc.py
work fine on the target platform O/S? If so, typepython vlc.py --version
in a shell or command window.
Is python-vlc.py
the same as vlc.py
? If so, then no, vlc.py
doesn't run on my computer well and has the following issues :
signature
from inspect
module. I referred to this SO answer, which suggested I had to use funcsigs
instead of inspect
funcsigs
. It kept throwing the error ImportError: No module named funcsigs
specifically for vlc.py
only (I quick tested it a new file in the same env and directory and the module seems to be importing and working just fine)Sorry, the Python file name is vlc.py
and not python-vlc
.
The question is whether vlc.py
runs at all in python on the target platform (Android?), where the missing symbol error occurs.
As a comparison, vlc.py
does not run in Pythonista on iOS due to different missing ctypes
symbols.
This looks rather like a kivy/ctypes issue, so I would dive into those issues. For instance, https://github.com/kivy/python-for-android/issues/1866 (a proposed solution at the end, about disabling python optimizations), or https://stackoverflow.com/questions/57655121/kivy-modulenotfounderror-no-module-named-ctypes-when-building-an-android-ap (installing libffi) could help.
The question is whether
vlc.py
runs at all in python on the target platform (Android?), where the missing symbol error occurs.
I don't know if this is the right answer, but as far as I know (and have researched). Probably no, python-vlc
doesn't run in python on Android platforms but does run on Desktop. And libvlcjni
works with Android but it runs Java/Kotlin as stated here
This looks rather like a kivy/ctypes issue, so I would dive into those issues. For instance, kivy/python-for-android#1866 (a proposed solution at the end, about disabling python optimizations), or https://stackoverflow.com/questions/57655121/kivy-modulenotfounderror-no-module-named-ctypes-when-building-an-android-ap (installing libffi) could help.
Yes, I did follow the first workaround you suggested and have included in my issue as well, libffi-dev
was already installed on my Ubuntu system but did nothing. Although now I have come to think that it may or may not work since on the website linked above they have stated vlc
runs in Java/Kotlin on Android and runs in Python on Desktop. I don't know if creating a recipe would help me make python-vlc
run in android
That is the issue. If there is no ctypes
in python
on kivy/Android, then vlc.py
will not work. In addition, vlc.py
and ctypes
need a libvlc
library from VLC https://www.videolan.org/vlc/ on Android and that may not exist either.
That is the issue. If there is no
ctypes
inpython
on kivy/Android, thenvlc.py
will not work. In addition,vlc.py
andctypes
need alibvlc
library from VLC https://www.videolan.org/vlc/ on Android and that may not exist either.
Yes that's what I was thinking but when I looked up the python-for-android's GitHub it did have a recipe for vlc
which should work but does nothing. If you can check the __init__.py
and see if you find something there, that would be really helpful.
So that's where my doubt lies if they've added a recipe for vlc
then it should compile but it doesn't.
The recipe does seem to have a recipe for VLC and a library. Try to build that and see if (a) that VLC runs on Android and (b) whether there is a library libvlc
on Android somewhere**.
But then, vlc.py
will stil not work due to one or more missing symbols in ctypes
. If it is only the PyFile_FromFd
symbol, try commenting out vlc.py
around line 386 and see if that works. Because, that symbol PyFile_FromFd
may not be necessary to run vlc.py
for your use case. However, all this is untested.
__
**) This is important, because vlc.py
and ctypes
must be able to find that libvlc
on Android. And since it is highly unlikely that the existing code at the top of vlc.py
will work correctly on Android, more changes in vlc.py
will be needed.
The recipe does seem to have a recipe for VLC and a library. Try to build that and see if (a) that VLC runs on Android and (b) whether there is a library
libvlc
on Android somewhere**.
I tried doing that by referring to the Buildozer's Contribute documentation, still the same error
But then,
vlc.py
will stil not work due to one or more missing symbols inctypes
. If it is only thePyFile_FromFd
symbol, try commenting outvlc.py
around line 386 and see if that works. Because, that symbolPyFile_FromFd
may not be necessary to runvlc.py
for your use case. However, all this is untested.
Tried this as well, it keeps giving me the same error but refers to a different file : .buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Lib/ctypes/__init__.py
at line 391 and 386 but the file doesn't contain PyFile_FromFd
at all.
I hope this issue was of some use, because I am beginning to think I should close this since it has very less to do with python-vlc
and more to do with p4a
and its recipes. If you agree on this, I'll close it.
It is clearly not an issue with python-vlc.
Hi @1MochaChan1. I'm developing an app with python-vlc and kivy and I'm facing the same issue. May I know if you were able to solve this problem?
Hi @1MochaChan1. I'm developing an app with python-vlc and kivy and I'm facing the same issue. May I know if you were able to solve this problem?
It can't be solved because python-vlc isn't built to be used by mobile devices. You gotta use VLC for Android if you want to make an app out of it.
@1MochaChan1 Did you end up to successfully use vlc for android with kivy in your app?
@1MochaChan1 Did you end up to successfully use vlc for android with kivy in your app?
No, VLC for Android
is not for kivy apps. It's for Java/Kotlin apps.
Here they've mentioned that python-vlc
is for Desktops apps made using python.
@1MochaChan1 Did you end up to successfully use vlc for android with kivy in your app?
No,
VLC for Android
is not for kivy apps. It's for Java/Kotlin apps.Here they've mentioned that
python-vlc
is for Desktops apps made using python.
Thanks, can I get your opinion pleace, is it theoretically possible to rewrite python-vlc and adapt it for use with android
python-vlc is not platform-dependent, it relies on ctypes and dynamic library bindings. If you have a working python+ctypes implementation through kivy, plus a libvlc library that is dynamically loaded, then it must be possible to use it on Android. I think the biggest issue, apart from having python+ctypes work (which seems to be the case for kivy), could be in the video output plugin (depending on the platforms, it may require some initialisation/embedding code).
python-vlc is not platform-dependent, it relies on ctypes and dynamic library bindings. If you have a working python+ctypes implementation through kivy, plus a libvlc library that is dynamically loaded, then it must be possible to use it on Android. I think the biggest issue, apart from having python+ctypes work (which seems to be the case for kivy), could be in the video output plugin (depending on the platforms, it may require some initialisation/embedding code).
Video output is not a problem for me. I have working version of this and it works perfect on my windows pc. The general issue is integration of vlc on android and use it through python.
I heard that this issue with python + ctypes in kivy appears in many cases and developers use cffi instead of ctypes. Maybe it is possible to use cffi in python-vlc?
In fact, integration with kivy does not require all the functionality of python-vlc, only some of it. Because of this, I can try to replace ctypes with cffi but I need to know if this is even possible.
python 3.8.5 python-vlc 3.0.12117
I am trying make an application that searches YouTube and plays a selected video's audio using
python-vlc
,kivymd
andpafy
. Pretty much an audio player but for YouTube (like YouTube music)When I am trying to compile my application using the command :
buildozer android debug deploy run logcat
It returns an AttributeError (mostly by the module ctypes) in log saying :
AttributeError: undefined symbol: PyFile_FromFd
Note
__init__.py
file for the recipe (I did refer top4a
andbuildozer
docs regarding recipes)setence("PYTHONOPTIMIZE", "2", 1);
from start.c in the p4a's src folder. The issue still persists.Buildozer Log
My GitHub Repository Containing The Project : https://github.com/1MochaChan1/pafy
Thank you for your time : )