【发布时间】:2015-01-09 17:07:07
【问题描述】:
我在 Google Cloud Platform 中有一个 VM 实例 (Ubuntu 14.04),我正在使用 Google Cloud Storage 进行测试。我想做的是创建一个使用 Cloud Storage Python 客户端库的简单脚本。此脚本必须列出现有存储桶的内容。这是我的脚本:
import logging
import os
import cloudstorage as gcs
from google.appengine.api import app_identity
# Retry can help overcome transient urlfetch or GCS issues, such as timeouts.
my_default_retry_params = gcs.RetryParams(initial_delay=0.2,
max_delay=5.0,
backoff_factor=2,
max_retry_period=15)
gcs.set_default_retry_params(my_default_retry_params)
stats = gcs.listbucket('/niksa')
for f in stats:
print f
我已经安装了 cloudstorage Python 模块,如HERE 所示。然后我更新了 PYTHONPATH 环境变量以包含该模块。 第一次运行脚本时,脚本抱怨缺少模块
ImportError: No module named google.appengine.api
为了解决这个问题,我使用以下命令安装了 Google App Engine:
curl https://sdk.cloud.google.com/ | bash
gcloud components update gae-python
然后我更新了 .bashrc 中的 PYTHONPATH 以指向包含 google python 模块的父文件夹。
再次运行脚本时,出现以下错误:
AssertionError: No api proxy found for service "memcache"
我的问题是:我会错过任何其他需要的模块/服务吗?从我找到的材料和文件中,没有提到任何内容。请注意,gsutil(命令行工具)按预期工作。
【问题讨论】:
标签: python google-app-engine ubuntu google-cloud-storage