【问题标题】:errorMessage": "'Neptune' object has no attribute 'stop_db_cluster"errorMessage": "'Neptune' 对象没有属性 'stop_db_cluster"
【发布时间】:2020-06-17 01:36:09
【问题描述】:

下面给出了我的 lambda 函数的代码

import boto3

client = boto3.client('neptune') response =
client.stop_db_cluster(DBClusterIdentifier='qa-n1-cluster')

输出如下

Response: { "errorMessage": "'Neptune' 对象没有属性 “stop_db_cluster”、“errorType”:“AttributeError”、“stackTrace”:[ " File \"/var/lang/lib/python3.8/imp.py\", line 234, in load_module\n return load_source(name, filename, file)\n", " File \"/var/lang/lib/python3.8/imp.py\",第 171 行,在 load_source\n 模块 = _load(spec)\n", " 文件 \"\",第 702 行,在 _load\n" 中, " 文件 \"\",第 671 行,在 _load_unlocked\n", " 文件 \"\",第 783 行,在 exec_module\n" 中, " 文件 \"\",第 219 行,在 _call_with_frames_removed\n" 中, " File \"/var/task/lambda_function.py\",第 4 行,在 \n 响应 = client.stop_db_cluster(DBClusterIdentifier='qa-n1-cluster')\n", " File \"/var/runtime/botocore/client.py\",第 514 行,在 getattr\n raise AttributeError(\n" ] }

【问题讨论】:

    标签: python aws-sdk boto3 amazon-neptune


    【解决方案1】:

    确切地说,您需要 boto 版本 1.11.721 (2020-02-12) 或更高版本。

    更改日志:https://github.com/aws/aws-sdk-java/blob/master/CHANGELOG.md

    1.11.721 2020-02-12

    亚马逊海王星

    此次发布启用了 Neptune start-db-cluster 和 stop-db-cluster。停止和启动 Amazon Neptune 集群可帮助您管理开发和测试环境的成本。您可以暂时停止集群中的所有数据库实例,而不是在每次使用集群时都设置和拆除所有数据库实例。

    升级您的 boto 版本,并确认您使用的是比此更新的版本。

    【讨论】:

      【解决方案2】:

      stop_db_cluster() 和 start_db_cluster() 是较新的 API(仅在几周前发布。请确认您使用的是最新版本的 boto3 吗?

      pip install --upgrade boto3

      【讨论】:

      • 是的,我参考了这个链接。docs.aws.amazon.com/lambda/latest/dg/python-package.html
      • 看起来,它在没有任何开发工具的情况下在终端上工作。自更新 boto3 版本以来,我们在 pycharm 中面临同样的问题。我当前的 boto3 版本在 pycharm 中是 1.12.19跨度>
      • C:\Users\keswarm\venv\AWS-jobs-automate\Scripts\python.exe C:/Users/keswarm/PycharmProjects/AWS-jobs-automate/neptune.py Traceback(最近最后调用):文件“C:/Users/keswarm/PycharmProjects/AWS-jobs-automate/neptune.py”,第 5 行,在 sn = client.stop_db_clusters(DBClusterIdentifier=clustername) 文件“C:\Users\ keswarm\venv\AWS-jobs-automate\lib\site-packages\botocore\client.py",第 566 行,在 getattr self.__class__.__name__, item) AttributeError: 'Neptune' object has没有属性“stop_db_clusters”进程以退出代码 1 结束
      • AWS-jobs-automate) C:\Users\keswarm\PycharmProjects\AWS-jobs-automate>pip show boto3 名称:boto3 版本:1.12.19 摘要:AWS SDK for Python 主页:github.com/boto/boto3 作者:Amazon Web Services 作者电子邮件:未知许可证:Apache 许可证 2.0 位置:c:\users\keswarm\venv\aws-jobs-automate\lib\site-packages 需要:jmespath、s3transfer、botocore跨度>
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-01
      • 2021-08-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多