GRPC and types import error in App Engine Datastore

前端 未结 3 685
迷失自我
迷失自我 2020-12-11 08:13

I deployed my application in App engine successfully. However, when I try to access my API, I receive the following message:

Error: Server Error Th

相关标签:
3条回答
  • 2020-12-11 08:33

    You are using the datastore client library, but this does not work in the standard environment. From the docs:

    You cannot use the Cloud Datastore client library with Python applications in the App Engine standard environment.

    You need to use the ndb package, as recommended in the docs (I believe there is also a REST API, but I've never used it).

    0 讨论(0)
  • 2020-12-11 08:42

    The first traceback appears to suggest that grpc is somehow involved, and that's a problem. According to comments on issue 149 grpc is not yet supported on GAE standard environment.

    But since you're on the GAE standard environment you should really use the recommended, GAE-optimized (and more feature-rich) NDB Client Library to access the datastore, not the generic google.cloud.datastore one (which might indeed include features not meeting the standard env sandbox restrictions).

    0 讨论(0)
  • 2020-12-11 08:52

    Somehow Google fixed the issue in 2019 so that your Python 2.7 apps running on Standard can now use the google.cloud.datastore library. To get rid of the grpc error, add these lines to the libraries section of your app.yaml file (or add it if not there already):

    libraries:
    - name: grpcio
      version: 1.0.0
    

    The statement from the accepted answer: "You cannot use the Cloud Datastore client library with Python applications in the App Engine standard environment," is no longer true and wiped from the docs.

    If porting to Cloud Datastore from the App Engine NDB library ( google.appengine.ext.ndb), it may be easier to first port to the Cloud NDB library (google.cloud.ndb, which is really just an "NDB client library" for Cloud Datastore). The step of adding the grpcio reference to app.yaml is described on this migration page.

    Another reason for this intermediate port is that Cloud NDB is also available in Python 3, giving you the opportunity to migrate your app from 2.x to 3.x and still have things work. Plus you get the added benefit of using App Engine's 2nd generation runtimes (Gen1 std only supports 2.7 while Flex supports 2.7 or 3.x, and Gen2 only supports 3.x.)

    Finally from there, port to Cloud Datastore (google.cloud.datastore). That intermediate step basically gets your "app infrastructure" ready for Cloud Datstore, and most of your heavy-lifting will be migrating your NDB data CRUDs to Cloud Datastore but not have to worry about these library issues which s/b taken care of by the above intermediate step. (I'll try to do a write-up on all this and will update this answer when I get something out there.)

    0 讨论(0)
提交回复
热议问题