Using Google Cloud Client Library and Google App Engine SDK Together

青春壹個敷衍的年華 提交于 2019-12-11 06:35:37

问题


I am trying to use the Google Cloud Client Library on Google App Engine. However, the Cloud Client Library and the App Engine SDK use google as an import name, and there are naming conflicts. How do I get them to work together?

When I try importing a Google Cloud Client Library module, I get the following error:

     >> import google.cloud.datastore
     Traceback (most recent call last):
       File "<console>", line 1, in <module>
       File "C:\[...]\libs\google\cloud\datastore\__init__.py", line 52, in <module>
         from google.cloud.datastore.batch import Batch
     ImportError: No module named cloud.datastore.batch

The reason this import error occurs is because the name google has already been imported from the App Engine SDK. This can be confirmed by running the command:

     >>> print google.__path__
     ['C:\\Program Files (x86)\\Google\\Cloud SDK\\google-cloud-sdk\\ platform\\google_appengine\\google']

Notice that the path points to the SDK.

Any ideas on how to resolve this name conflict?

来源:https://stackoverflow.com/questions/40660397/using-google-cloud-client-library-and-google-app-engine-sdk-together

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