GAE:断言错误:找不到服务“datastore_v3"的 api 代理; [英] GAE: AssertionError: No api proxy found for service "datastore_v3"

查看:21
本文介绍了GAE:断言错误:找不到服务“datastore_v3"的 api 代理;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写简单的代码来访问开发服务器.模拟的开发服务器和数据存储都已在本地启动.

I'm writing simple to code to access dev server. Both dev server and datastore emulated have been started locally.

from google.appengine.ext import ndb

class Account(ndb.Model):
    name = ndb.StringProperty()

acc = Account(name=u"test").put()
print(acc)

错误:

AssertionError: No api proxy found for service "datastore_v3"

我尝试设置: export DATASTORE_EMULATOR_HOST=localhost:8760 .它没有帮助.

I tried to set: export DATASTORE_EMULATOR_HOST=localhost:8760 . It does not help.

$ dev_appserver.py  ./app.yaml 
WARNING  2017-02-20 06:40:23,130 application_configuration.py:176] The "python" runtime specified in "./app.yaml" is not supported - the "python27" runtime will be used instead. A description of the differences between the two can be found here:
https://developers.google.com/appengine/docs/python/python25/diff27
INFO     2017-02-20 06:40:23,131 devappserver2.py:764] Skipping SDK update check.
INFO     2017-02-20 06:40:23,508 api_server.py:268] Starting API server at: http://localhost:53755
INFO     2017-02-20 06:40:23,514 dispatcher.py:199] Starting module "default" running at: http://localhost:8080
INFO     2017-02-20 06:40:23,517 admin_server.py:116] Starting admin server at: http://localhost:8000

推荐答案

GAE 应用程序代码不能作为独立 python 应用程序运行,它只能在GAE 应用程序内部运行它在您的开发服务器内运行.通常作为处理程序代码的一部分,通过对开发服务器的 http 请求触发.

GAE app code cannot run as a standalone python app, it can only run inside a GAE app which runs inside your dev server. Typically as part of a handler code, triggered via http requests to the dev server.

您需要将该代码放入其中一个应用程序处理程序中.例如,在 main.pyPython App Engine 标准环境快速入门(实际上最好使用 post() 方法,因为您的代码正在写入数据存储区).

You need to put that code inside one of your app handlers. For example inside the get() method of the MainPage handler from main.py in the Quickstart for Python App Engine Standard Environment (actually it'd be better in a post() method since your code is writing to the datastore).

这篇关于GAE:断言错误:找不到服务“datastore_v3"的 api 代理;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆