android - Python、Kivy、Buildozer : error using python-firebase/requests

标签 android python-2.7 firebase kivy buildozer

[ python = 2.7]

我最近开始使用kivy(最新版本)为android 开发一个应用程序。为此,我使用 buildozer(最新版本)来创建 apk 文件。现在即使使用 python-firebase 模块,我的电脑也一切正常。将数据发送到 firebase 在线数据库。但是当我想在手机上使用 python 模块 python-firebase(基于模块 requests)时,应用程序在加载几秒钟后崩溃。

目前,我在 buildozer.spec 中的要求是 plyer 和 kivy。如果我尝试将请求添加到此列表,我会收到错误消息:

在virtualenv中安装requirements

运行'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> ...

没有这样的选项:--download-cache

命令失败:pip install --download-cache=/home/notwaka/.buildozer/cache --target=/home/notwaka/Desktop/Gps/.buildozer/applibs 请求

Buildozer 执行最后一条命令失败

我是否需要将请求添加到需求中,因为它是在使用 buildozer 的文档中的示例中完成的?我该怎么做才能让 python-firebase 在我的 android 设备上运行?我不知道如何制作食谱,也找不到任何关于此的好文档。制作食谱可行吗?有没有人试图让 firebase 在 android 上与 python 一起工作?

提前致谢!

编辑:

'# 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
'

最佳答案

在 python Kivy 上运行的 Firebase 存在问题。参见 https://github.com/ozgur/python-firebase/pull/26

这是因为 Firebase 使用的 Kivy 不完全支持多核处理。这导致了 kivy Firebase 应用程序崩溃。

我还没有尝试过这个补丁,但是看了评论,Zkanda 做得很好。这可能就是您正在寻找的。


或者,您可以使用 json 从 Firebase 下载数据。

我在使用 Firebase 时所做的是使用 python 的原生 Requests 库对 Firebase 进行 json 调用,他们支持 https。

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

在您的 buildozer.spec 文件中,在 Requirements 下,包括

requirements = kivy,requests,simplejson,openssl 

openssl是支持https,simplejson是支持json


关于android - Python、Kivy、Buildozer : error using python-firebase/requests,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36063407/

相关文章:

python - 使用 webapp2 在 Python 中的 Google App Engine 上进行 session

android - 删除 Firebase Android 应用程序,然后在另一个项目中使用其 SHA1 和包名称

node.js - 如何在 Cloud Functions for Firebase 中获取服务器时间戳?

Firebase 仅在成功付款后注册用户

android - 本地嵌入的 ML 套件库是否对谷歌服务器进行任何网络调用?

android - Google Play 应用签名流程

android - Android 中 Google map 上的图像图 block

android - For循环多个数组并保留空行

python - 使用 pytz 的日期时间时区转换

python - 如何在 python 2.7 中删除 ) ' 和 , ?