gpt4 book ai didi

python - 无法让 gcloud 与 Python 和 Pycharm 配合使用

转载 作者:太空宇宙 更新时间:2023-11-03 16:07:18 26 4
gpt4 key购买 nike

我正在尝试从本地计算机连接到 Google App Engine 数据存储区。我花了一整天的时间来研究这个问题,但没有任何运气。

我已经尝试过这里的方法(以及SO的许多其他建议,例如 Using gcloud-python in GAEUnable to run dev_appserver.py with gcloud ):

How to access a remote datastore when running 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

我在这里做错了什么?

最佳答案

google-cloud 库是 not working on App Engine而且很可能您甚至不需要这样做,因为您可以使用内置功能。<​​/p>

来自official docs你可以像这样使用它:

import cloudstorage as gcs

关于python - 无法让 gcloud 与 Python 和 Pycharm 配合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39666449/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com