简体   繁体   中英

Python, Kivy, Buildozer: error using python-firebase/requests

[python = 2.7]

I recently started to use kivy(newest version) to develop an app for android. For this I use buildozer(newest version) to create the apk file. Now everything works fine on my computer even using the python-firebase module. To send data to the firebase online database. But when I want to use the python module python-firebase (that is based on the module requests ) on my phone the app crashes after it loads for a few seconds.

For now my requirements in the buildozer.spec are plyer and kivy. If I try to add requests to this list, I get the error:

Install requirement requests in virtualenv

Run 'pip install --download-cache=/home/notwaka/.buildozer/cache --target=/home/notwaka/Desktop/Gps/.buildozer/applibs requests'

Cwd /home/notwaka/Desktop/Gps/.buildozer

Usage:   
  pip install [options] <requirement specifier> [package-index-options] ...
  pip install [options] -r <requirements file> [package-index-options] ...
  pip install [options] [-e] <vcs project url> ...
  pip install [options] [-e] <local project path> ...
  pip install [options] <archive url/path> ...

no such option: --download-cache

Command failed: pip install --download-cache=/home/notwaka/.buildozer/cache --target=/home/notwaka/Desktop/Gps/.buildozer/applibs requests

Buildozer failed to execute the last command

Do I need to add requests to the requirements, since it is done in an example in the documentation of using buildozer? What can I do to make python-firebase working on my android device? I have no knowledge about how to make a recipe and can´t find any good documentation about this. Could making a recipe work? Has anyone tried to get firebase working with python on android?

Thanks in advance!

Edit:

'# Check application requirements
# Run './distribute.sh -l'
# Cwd /home/notwaka/Desktop/try/.buildozer/android/platform/python-for-android
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
# Remove directory and subdirectory /home/notwaka/Desktop/try/.buildozer/applibs
# Create directory /home/notwaka/Desktop/try/.buildozer/applibs
# Run 'bash -c "source venv/bin/activate && env"'
# Cwd /home/notwaka/Desktop/try/.buildozer
LC_PAPER=nl_NL.UTF-8
XDG_VTNR=7
LC_ADDRESS=nl_NL.UTF-8
XDG_SESSION_ID=c2
CLUTTER_IM_MODULE=xim
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/notwaka
SELINUX_INIT=YES
LC_MONETARY=nl_NL.UTF-8
GPG_AGENT_INFO=/run/user/1000/keyring-wWFm7x/gpg:0:1
VTE_VERSION=3409
SHELL=/bin/bash
TERM=xterm
LC_NUMERIC=nl_NL.UTF-8
WINDOWID=65011724
UPSTART_SESSION=unix:abstract=/com/ubuntu/upstart-session/1000/1938
GNOME_KEYRING_CONTROL=/run/user/1000/keyring-wWFm7x
GTK_MODULES=overlay-scrollbar:unity-gtk-module
USER=notwaka
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:
LC_TELEPHONE=nl_NL.UTF-8
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
SSH_AUTH_SOCK=/run/user/1000/keyring-wWFm7x/ssh
DEFAULTS_PATH=/usr/share/gconf/ubuntu.default.path
VIRTUAL_ENV=/home/notwaka/Desktop/try/.buildozer/venv
XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/usr/share/upstart/xdg:/etc/xdg
PATH=/home/notwaka/Desktop/try/.buildozer/venv/bin:/home/notwaka/.buildozer/android/platform/apache-ant-1.9.4/bin:/home/notwaka/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
DESKTOP_SESSION=ubuntu
QT_IM_MODULE=ibus
ANDROIDAPI=19
QT_QPA_PLATFORMTHEME=appmenu-qt5
LC_IDENTIFICATION=nl_NL.UTF-8
JOB=gnome-session
PWD=/home/notwaka/Desktop/try/.buildozer
XMODIFIERS=@im=ibus
LANG=en_US.UTF-8
GNOME_KEYRING_PID=1936
GDM_LANG=en_US
MANDATORY_PATH=/usr/share/gconf/ubuntu.mandatory.path
LC_MEASUREMENT=nl_NL.UTF-8
ANDROIDNDK=/home/notwaka/.buildozer/android/platform/android-ndk-r9c
IM_CONFIG_PHASE=1
COMPIZ_CONFIG_PROFILE=ubuntu
PS1=(venv) 
GDMSESSION=ubuntu
PACKAGES_PATH=/home/notwaka/.buildozer/android/packages
SESSIONTYPE=gnome-session
HOME=/home/notwaka
SHLVL=2
XDG_SEAT=seat0
LANGUAGE=en_US
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
UPSTART_INSTANCE=
UPSTART_EVENTS=started starting
ANDROIDSDK=/home/notwaka/.buildozer/android/platform/android-sdk-20
LOGNAME=notwaka
XDG_DATA_DIRS=/usr/share/ubuntu:/usr/share/gnome:/usr/local/share/:/usr/share/
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-lqf94SPFU0
QT4_IM_MODULE=xim
LESSOPEN=| /usr/bin/lesspipe %s
ANDROIDNDKVER=r9c
UPSTART_JOB=unity-settings-daemon
INSTANCE=Unity
TEXTDOMAIN=im-config
DISPLAY=:0
XDG_RUNTIME_DIR=/run/user/1000
XDG_CURRENT_DESKTOP=Unity
GTK_IM_MODULE=ibus
LESSCLOSE=/usr/bin/lesspipe %s %s
LC_TIME=nl_NL.UTF-8
TEXTDOMAINDIR=/usr/share/locale/
LC_NAME=nl_NL.UTF-8
XAUTHORITY=/home/notwaka/.Xauthority
COLORTERM=gnome-terminal
_=/usr/bin/env
# Install distribute
# Run 'curl http://python-distribute.org/distribute_setup.py | venv/bin/python'
# Cwd /home/notwaka/Desktop/try/.buildozer
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
# Install requirement pygments in virtualenv
# Run 'pip install --download-cache=/home/notwaka/.buildozer/cache --target=/home/notwaka/Desktop/try/.buildozer/applibs pygments'
# Cwd /home/notwaka/Desktop/try/.buildozer

Usage:   
  pip install [options] <requirement specifier> [package-index-options] ...
  pip install [options] -r <requirements file> [package-index-options] ...
  pip install [options] [-e] <vcs project url> ...
  pip install [options] [-e] <local project path> ...
  pip install [options] <archive url/path> ...

no such option: --download-cache
# Command failed: pip install --download-cache=/home/notwaka/.buildozer/cache --target=/home/notwaka/Desktop/try/.buildozer/applibs pygments
# 
# Buildozer failed to execute the last command
# The error might be hidden in the log above this error
# Please read the full log, and search for it before
# raising an issue with buildozer itself.
# In case of a bug report, please add a full log with log_level = 2
'

There is an issue for Firebase working on python Kivy. See https://github.com/ozgur/python-firebase/pull/26

This is because multicore processing is not fully supported on Kivy, which is used by Firebase. This caused the crash on kivy Firebase apps.

I haven't tried the patch yet, but looking at the comments, Zkanda did good. This might be what you're looking for.


Alternatively, you can use json to download data from Firebase.

What I did to use Firebase was to use python's native Requests library to make a json call to Firebase, which they support with https.

import json, requests
url = "https://myfirebaseurl.firebaseio.com/some_database.json"
resp = requests.get(url = url, json = {'create':True})
data = resp.json()

In your buildozer.spec file, under the Requirements, include

requirements = kivy,requests,simplejson,openssl 

openssl is to support https, simplejson is for json.


no such option: --download-cache

This reflects a bug in python-for-android that is now fixed. If you make buildozer re-download python-for-android, eg by deleting the .buildozer dir in your build directory, it should work.

You can also edit the current downloaded distribute.sh to remove the --download-cache option when calling pip.

I tried the suggested solution when encountering a similar issue with pygments, and it didn't work for me either. I increased log levels and found that pygments was being downloaded to lib64/python on my distro, whereas pip was looking for lib/python.

It appears to be related to this pip issue: https://github.com/pypa/pip/issues/3056

I added a setup.cfg file in the .buildozer folder for my app, containing:

[install]
install-purelib=$base/lib64/python

and my app now installs successfully.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM