我正在尝试从本地计算机连接到 Google App Engine 数据存储区。我花了一整天的时间来研究这个,没有任何运气。
我在这里尝试了这种方法(以及来自 SO 的许多其他建议,例如在 GAE 中使用 gcloud-python和Unable to run dev_appserver.py with gcloud):
运行 dev_appserver.py 时如何访问远程数据存储?
我首先根据谷歌的描述安装了 gcloud: https ://cloud.google.com/appengine/docs/python/tools/using-libraries-python-27
根据描述,我应该将以下内容添加到我的 appengine_config.py 中:
from google.appengine.ext import vendor
vendor.add('lib')
如果我这样做,我会收到一条错误消息ImportError: No module named gcloud
如果我随后将代码移动到我的 main.py,它似乎会拾取 lib 文件夹和那里的模块。这对我来说似乎有点奇怪,因为我认为 appengine_config 首先运行以确保初始化。但现在我得到以下堆栈跟踪:
ERROR 2016-09-23 17:22:30,623 cgi.py:122] Traceback (most recent call last):
File "/Users/thomasd/Documents/github/myapp/main.py", line 10, in <module>
from gcloud import datastore
File "/Users/thomasd/Documents/github/myapp/lib/gcloud/__init__.py", line 17, in <module>
from pkg_resources import get_distribution
File "/Users/thomasd/Documents/github/myapp/lib/pkg_resources/__init__.py", line 2985, in <module>
@_call_aside
File "/Users/thomasd/Documents/github/myapp/lib/pkg_resources/__init__.py", line 2971, in _call_aside
f(*args, **kwargs)
File "/Users/thomasd/Documents/github/myapp/lib/pkg_resources/__init__.py", line 3013, in _initialize_master_working_set
dist.activate(replace=False)
File "/Users/thomasd/Documents/github/myapp/lib/pkg_resources/__init__.py", line 2544, in activate
declare_namespace(pkg)
File "/Users/thomasd/Documents/github/myapp/lib/pkg_resources/__init__.py", line 2118, in declare_namespace
_handle_ns(packageName, path_item)
File "/Users/thomasd/Documents/github/myapp/lib/pkg_resources/__init__.py", line 2057, in _handle_ns
loader.load_module(packageName)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 246, in load_module
mod = imp.load_module(fullname, self.file, self.filename, self.etc)
File "/Library/Python/2.7/site-packages/google/cloud/logging/__init__.py", line 18, in <module>
File "/usr/local/google_appengine/google/appengine/tools/devappserver2/python/sandbox.py", line 999, in load_module
raise ImportError('No module named %s' % fullname)
ImportError: No module named google.cloud.logging.client
我在这里做错了什么?