【发布时间】:2020-06-02 12:55:09
【问题描述】:
她是我的 main.py
# -*- coding: utf-8 -*-
from kivy.app import App
from kivy.uix.screenmanager import ScreenManager,Screen,FadeTransition
from kivy.lang import Builder
from kivy.properties import ObjectProperty, StringProperty
from kivy.core.text import LabelBase
import gspread
from oauth2client.service_account import ServiceAccountCredentials
from kivy.storage.jsonstore import JsonStore
class MainWindow(Screen):
pass
class SecondWindow(Screen):
stored_data = ObjectProperty(None)
def __init__(self,*args,**kwargs):
super(Screen,self).__init__(*args,**kwargs),
self.stored_data = JsonStore('data.json')
def gonder(self):
name = self.ids.name.text
scope = ["https://spreadsheets.google.com/feeds",
'https://www.googleapis.com/auth/spreadsheets',
"https://www.googleapis.com/auth/drive.file",
"https://www.googleapis.com/auth/drive"]
creds = ServiceAccountCredentials.from_json_keyfile_name("creds.json", scope)
client = gspread.authorize(creds)
sheet = client.open("verigonder").sheet1
sheet.append_row([name])
class ThirdWindow(Screen):
pass
class WindowManager(ScreenManager):
pass
class mainApp(App):
def build(self):
return Builder.load_file("my.kv")
if __name__ == "__main__":
mainApp().run()
这里有 buildozer.spec 要求
requirements = python3,kivy,gspread,oauth2client,google-auth-oauthlib,httplib2,pyasn1,pyasn1-modules,rsa,request,google
和调试日志
06-02 15:25:27.121 25609 25949 I python : Traceback (most recent call last):
06-02 15:25:27.121 25609 25949 I python : File
"/home/ademberkaksoy/sheet/.buildozer/android/app/main.py", line 8, in <module>
06-02 15:25:27.121 25609 25949 I python : File
"/home/ademberkaksoy/sheet/.buildozer/android/platform/build-armeabi-v7a/build/python-
installs/myapp/gspread/__init__.py", line 16, in <module>
06-02 15:25:27.121 25609 25949 I python : File
"/home/ademberkaksoy/sheet/.buildozer/android/platform/build-armeabi-v7a/build/python-
installs/myapp/gspread/auth.py", line 12, in <module>
06-02 15:25:27.121 25609 25949 I python : ModuleNotFoundError: No module named 'google'
06-02 15:25:27.121 25609 25949 I python : Python for android ended.
它仍然给出同样的错误。我需要做什么来解决这种情况?它可以在笔记本电脑上运行,但由于此错误,它不能在 android 上运行。我认为这一切都与 gspread 有关,但问题出在哪里,为什么仍然会出现此错误?
【问题讨论】:
-
您是否安装了 GSpread 工作所需的库?检查您的 gspread 安装,并检查您是否也安装了 google-api-python-client。运行
pip install google-api-python-client。 -
我必须这样做吗?因为它的构建器错误。它在电脑上工作
标签: android google-sheets kivy apk buildozer