GAE: AssertionError: No api proxy found for service “datastore_v3”

梦想的初衷 提交于 2019-12-01 05:48:59

问题


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)

Error:

AssertionError: No api proxy found for service "datastore_v3"

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

回答1:


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.

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).



来源:https://stackoverflow.com/questions/42338094/gae-assertionerror-no-api-proxy-found-for-service-datastore-v3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!