gpt4 book ai didi

python - 从 oauth2client.appengine 导入 o​​auth2decorator_from_clientsecrets ImportError : No module named appengine

转载 作者:太空狗 更新时间:2023-10-30 03:05:14 30 4
gpt4 key购买 nike

我在尝试运行我的应用程序时遇到以下错误

from oauth2client.appengine import oauth2decorator_from_clientsecrets
ImportError: No module named appengine

这是我的main.py代码

import httplib2
import os
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from oauth2client.appengine import oauth2decorator_from_clientsecrets

CLIENT_SECRETS = os.path.join(os.path.dirname(__file__), 'client_secrets.json')

decorator = oauth2decorator_from_clientsecrets(CLIENT_SECRETS,
'https://www.googleapis.com/auth/bigquery')

class MainHandler(webapp.RequestHandler):
@decorator.oauth_required
def get(self):
self.response.out.write("Hello Dashboard!\n")

application = webapp.WSGIApplication([
('/', MainHandler),
], debug=True)

def main():
run_wsgi_app(application)

if __name__ == '__main__':
main()

这是我的 app.yaml

application: hellomydashboard
version: 1
runtime: python27
api_version: 1
threadsafe: false

handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico

- url: /oauth2callback
script: oauth2client/appengine.py

- url: .*
script: main.app

最佳答案

这里的第一个问题是您已将/oauth2callback 处理程序添加到 app.yaml。请在此处查看有关装饰器的文档:

https://developers.google.com/api-client-library/python/platforms/google_app_engine?hl=en#Decorators

或者这里的示例代码:

http://code.google.com/p/google-api-python-client/source/browse/samples/appengine/main.py

至于导入错误,您是否将库的代码安装到您的 App Engine 项目中?最简单的方法是下载最新的 google-api-python-client-gae-NN.zip 并将其直接解压缩到您的项目中。

http://code.google.com/p/google-api-python-client/downloads/detail?name=google-api-python-client-gae-1.0.zip&can=2

关于python - 从 oauth2client.appengine 导入 o​​auth2decorator_from_clientsecrets ImportError : No module named appengine,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13212115/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com