【问题标题】:datastore AttributeError: 'module' object has no attribute 'set_defaults'数据存储区 AttributeError:“模块”对象没有属性“set_defaults”
【发布时间】:2015-01-22 02:10:28
【问题描述】:

从这里:http://googlecloudplatform.github.io/gcloud-python/datastore-api.html

from gcloud import datastore
datastore.set_defaults()

解决这个错误:

Traceback (most recent call last):    
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'set_defaults'
This happens in Windows 7 and GCE standard setup.  

$ gcloud version
Google Cloud SDK 0.9.31
bq 2.0.18
bq-win 2.0.17
compute 2014.09.09
core 2014.09.02
core-win 2014.06.03
dns 2014.09.02
gae-java 1.9.10
gae-java-win 1.9.3
gcutil 1.16.5
gcutil-win 1.16.0
gsutil 4.5
gsutil-win 3.42
sql 2014.09.02
windows-ssh-tools 2014.07.15

似乎调用了错误版本的 gcloud.datastore。

【问题讨论】:

  • 您可以运行pip list 来显示gcloud 库吗?您使用的 gcloud 命令用于 SDK 命令行工具(是的,令人困惑)
  • 谢谢。 gcloud (0.3.0) 我猜有办法转到旧版本。

标签: python google-compute-engine gcloud


【解决方案1】:

我启动了一个计算实例来尝试这个包,实际上也遇到了同样的问题。不过这是意料之中的。

在撰写本文时,最新版本的 gcloud(PyPI 包)为 0.3.0。如果您查看diff between the release tag and master 并检查更改的文件。很明显,自上一个包以来,master 有很多 API 更改,包括您尝试调用的函数。

您可能需要从源代码中签出 gcloud-python 并以这种方式安装它以使用更新的 API 功能。

【讨论】:

猜你喜欢
  • 2016-07-30
  • 2021-01-28
  • 2018-04-18
  • 1970-01-01
  • 1970-01-01
  • 2010-11-18
相关资源
最近更新 更多