Kivy and external libraries issues

1,162 views
Skip to first unread message

Kai On Wong

unread,
May 2, 2016, 11:41:07 AM5/2/16
to Kivy users support
I am having issues with creating Kivy App with external libraries import.

1) I have tried creating apk using buildozer. The simple app like "hello world" works fine so it suggests my environment was set up properly. I have also tested a simple app with numpy import also works by specifying in the .spec file. But when I tried importing the libraries I wanted (ie: pydictionary and pyttsx), the .apk file was still created at the end, but when I tried to open it, it crashes.

2) I have also tested on Kivy Launcher, same thing happened basically. The .py with import from pydictionary and pyttsx crashes, while the simpler app with no import or with numpy import works.

How can I properly import external libraries in Kivy app? 

ZenCODE

unread,
May 2, 2016, 3:49:31 PM5/2/16
to Kivy users support
So, when you deploy with buildozer, you are deploying to different operating systems, each using self-contained python distributions.

If the library you want to include is pure python, the easiest way is just to copy the module into your app folder. That should then work on all platforms.

If the library uses binaries, these will be platform specific and you need to ensure these binaries are created and included correctly for the target platform. You can do this by using existing or creating recipes for the libraries/target platforms in question. e.g.

https://python-for-android.readthedocs.io/en/latest/recipes/

For iOs: https://github.com/kivy/kivy-ios/tree/master/recipes

That's about where my knowledge end. Hope it helps :-)

Kai On Wong

unread,
May 2, 2016, 10:36:37 PM5/2/16
to Kivy users support
How can I check if it is pure python or not? I am using pydictionary and pyttsx. 

ZenCODE

unread,
May 3, 2016, 2:42:12 PM5/3/16
to Kivy users support
Good question. Not sure if there is simple way, but reading their docs and looking at the download is a goods start. Both PyDictioary and pyttsx are downloadable as zips, so are almost certainly pure python (as it just requires unzipping). To check, just look through the extracted folders to make sure they don't contain any binaries...

If not, just copy those folders into you app folder and try it? Good luck :-)

Kai On Wong

unread,
May 3, 2016, 9:10:41 PM5/3/16
to Kivy users support
Do I simply download the zip file and then unzip the base directory (ie: PyDictionary-1.3.4) into the same directory as the main.py, and then 'buildozer android debug'? I don't need to specify anything to make the connection? Buildozer is that smart in detecting dependencies?
Message has been deleted

ZenCODE

unread,
May 4, 2016, 2:23:08 PM5/4/16
to Kivy users support
Yes, but without the -1.3.4. Buildozer does not figure anything out. When you run you app, and looks in subfolders for the '__init__.py' file and builds you module tree as normal from there. So "from PyDictionary import X" just looks in the PyDictionary subfolder...
Message has been deleted

Tanay Chowdhury

unread,
May 11, 2016, 5:27:58 PM5/11/16
to Kivy users support
I guess at present the easiest way to check whether a python library is supported or not is to 
include that in the following section of  buildozer.spec upon its creation
# (list) Application requirements
# comma seperated e.g. requirements = sqlite3,kivy
requirements = kivy,numpy,<library name>

If the library isn't supported buildozer will throw an error with supported library names once you run buildozer -v android debug

At present the supported libraries are

Available modules: android apsw audiostream bidi boost cherrypy c_igraph click cprotobuf cymunk django docutils ecdsa enum34 evdev ffmpeg ffmpeg2 ffpyplayer ffpyplayer_tito flask freetype gevent greenlet harfbuzz hostpython igraph itsdangerous jinja2 jpeg kivent_core kivent_cymunk kivy leveldb libevent libpq libsodium libswift libtorrent libxml2 libxslt libyaml lxml m2crypto markupsafe midistream msgpack mysql_connector netifaces numpy opencv openssl paramiko pil plyer plyvel png polygon protobuf psutil psycopg2 pyasn1 pycrypto pygame pyjnius pylibpd pyopenssl pyparsing pyqrcode python pyyaml sdl setuptools six sqlalchemy sqlite3 storm swift thrift twisted txws werkzeug wokkel zeroconf zope#
Reply all
Reply to author
Forward
0 new messages