I created an app using Scikit-learn and Kivy and it was built with Buildozer.
This is the code of main.py :
# coding=utf-8
import kivy
import sys
kivy.require('1.9.0')
from kivy.app import App
from kivy.uix.label import Label
class MyApp(App):
def build(self):
try:
from sklearn import svm, datasets
except:
return Label(text=str(sys.exc_info()[1]))
else:
return Label(text='Scikit-learn OK')
if __name__ == '__main__':
MyApp().run()
I specified Scikit-learn in the requirements in buildozer.spec :
[app]
title = Kivyris
package.name = kivyris
package.domain = org.test
source.dir = .
source.include_exts = py,png,jpg,kv,atlas
version = 0.1
requirements = kivy,numpy,scipy,scikit-learn
orientation = landscape
fullscreen = 1
log_level = 2
warn_on_root = 1
I ran buildozer android_new debug deploy run
(no error, APK file created and deployed) but I have the following error when the app is launched :
Cannot load library:
Contents of /data/data/org.test.kivyris/files/app/lib/python2.7/site-packages/sklearn/check_build: __init.pyo setup.pyo _check_build.so
It seems that sckikit-learn has not been built correctly.
If you have installed scikit-learn from source, please do not forget to build the package before using it; run
python setup.py install
ormake
in the source directory.If you have used an installer, please check that it is suited for your Python version, your operating system and your platform.
On Windows and Ubuntu using python main.py
it works well :
Scikit-Learn OK
I installed Scikit-learn using sudo apt-get install python-scikits-learn
on Ubuntu 16.04 LTS. This is some informations from the device on which I ran the app :
- import platform failed; platform.platform() : I couldn't get this info (app failed to launch), but it's an Android 5.1.1
- import sys OK; sys.version : 2.7.2 (default, Mar 6 2017, 06:05:36) [GCC 4.8]
- import numpy OK; Numpy.version : 1.9.2
- import scipy OK; Scipy.version : 0.18.1
- import sklearn : error (see above).
I tried a few things unsuccessfully, so I looked online :
- https://unix.stackexchange.com/questions/240239/building-python-packages-succeeds-but-package-is-improperly-built/240260 : didn't work for me.
- Import scikit in C# application : not really what I was looking for.
- https://github.com/scikit-learn/scikit-learn/issues/433 : works for Mac, not for Ubuntu.
- Cannot import Scikit-Learn : scipy works for me.
I didn't find anything useful and I have no idea how to solve that. Any idea please ?
Thank you.