简体   繁体   English

Python,Kivy,Buildozer:使用python-firebase / requests时出错

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

[python = 2.7] [python = 2.7]

I recently started to use kivy(newest version) to develop an app for android. 我最近开始使用kivy(最新版本)为Android开发应用程序。 For this I use buildozer(newest version) to create the apk file. 为此,我使用buildozer(最新版本)来创建apk文件。 Now everything works fine on my computer even using the python-firebase module. 现在,即使使用python-firebase模块,我的计算机上的一切也能正常工作。 To send data to the firebase online database. 将数据发送到firebase在线数据库。 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. 但是当我想在我的手机上使用python模块python-firebase (基于模块请求 )时,应用程序在加载几秒钟后崩溃。

For now my requirements in the buildozer.spec are plyer and kivy. 现在我对buildozer.spec的要求是plyer和kivy。 If I try to add requests to this list, I get the error: 如果我尝试向此列表添加请求,则会收到错误消息:

Install requirement requests in virtualenv 在virtualenv中安装需求请求

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

Cwd /home/notwaka/Desktop/Gps/.buildozer 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 没有这样的选择:--download-cache

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

Buildozer failed to execute the last command Buildozer无法执行最后一个命令

Do I need to add requests to the requirements, since it is done in an example in the documentation of using buildozer? 我是否需要向需求添加请求,因为它是在使用buildozer的文档中的示例中完成的? What can I do to make python-firebase working on my android device? 我该怎么做才能让python-firebase在我的Android设备上运行? 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? 有没有人试图让firebase在android上运行python?

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. Firebase在python Kivy上运行时会遇到问题。 See https://github.com/ozgur/python-firebase/pull/26 请参阅https://github.com/ozgur/python-firebase/pull/26

This is because multicore processing is not fully supported on Kivy, which is used by Firebase. 这是因为FireStation使用的Kivy并不完全支持多核处理。 This caused the crash on kivy Firebase apps. 这导致kivy Firebase应用程序崩溃。

I haven't tried the patch yet, but looking at the comments, Zkanda did good. 我还没有尝试过补丁,但看着评论,Zkanda做得很好。 This might be what you're looking for. 这可能就是你要找的东西。


Alternatively, you can use json to download data from Firebase. 或者,您可以使用json从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. 我使用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()

In your buildozer.spec file, under the Requirements, include 在您的buildozer.spec文件中,在Requirements,include下

requirements = kivy,requests,simplejson,openssl 

openssl is to support https, simplejson is for json. openssl是支持https,simplejson是支持json。


no such option: --download-cache 没有这样的选择:--download-cache

This reflects a bug in python-for-android that is now fixed. 这反映了现在修复的python-for-android中的一个错误。 If you make buildozer re-download python-for-android, eg by deleting the .buildozer dir in your build directory, it should work. 如果你让buildozer重新下载python-for-android,例如删除你的build目录中的.buildozer目录,它应该可以工作。

You can also edit the current downloaded distribute.sh to remove the --download-cache option when calling pip. 您还可以编辑当前下载的distribute.sh以在调用pip时删除--download-cache选项。

I tried the suggested solution when encountering a similar issue with pygments, and it didn't work for me either. 当遇到与pygments类似的问题时,我尝试了建议的解决方案,但它对我也没有用。 I increased log levels and found that pygments was being downloaded to lib64/python on my distro, whereas pip was looking for lib/python. 我增加了日志级别,发现pytrments正在我的发行版上下载到lib64 / python,而pip正在寻找lib / python。

It appears to be related to this pip issue: https://github.com/pypa/pip/issues/3056 它似乎与这个pip问题有关: https//github.com/pypa/pip/issues/3056

I added a setup.cfg file in the .buildozer folder for my app, containing: 我在我的应用程序的.buildozer文件夹中添加了一个setup.cfg文件,其中包含:

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

and my app now installs successfully. 我的应用程序现在安装成功。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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