Python导入boto3错误: cannot import name ClientError

标签 python amazon-web-services boto3

我正在尝试将 AWS Simple Email Service 与 Python 结合使用。我关注了Send an Email Using the AWS SDK for Python (Boto) sample code .程序无法正确导入boto3。

当它第一次尝试导入 boto3 时,Python 给出错误 ImportError: cannot import name ClientError

如果我再次尝试导入,错误变为ImportError: cannot import name certs

我还检查了安装的 boto3 版本,它与示例代码的版本相同。

boto3 Version: 1.4.4
botocore Version: 1.5.95

最佳答案

您的 boto3 和 botocore 版本非常过时。首先安装更新版本。我还会更新您安装的 AWS CLI 版本。

pip install boto3 --upgrade
pip install awscli --upgrade

[评论后更新]

更新后,在执行“aws --version”时仔细检查您是否至少有以下版本:

aws-cli/1.14.2 Python/2.7.9 Windows/8 botocore/1.8.6

接下来尝试从 CLI 发送电子邮件。以下是 Windows CMD 提示符的脚本。使用经过 SES 验证的有效电子邮件地址进行修改。稍作修改的同一命令将适用于 Linux。

set FROM=from@mydomain.com
set TO=to@mydomain.com
aws ses send-email --from %FROM% --destination ToAddresses=%TO% --message Subject={Data="Hello world
"},Body={Text={Data="Hello World"}}

关于Python导入boto3错误: cannot import name ClientError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47942154/

相关文章:

python - scapy 没有发送数据包

python - 我想将所有工作表添加到 Excel 中的一张工作表中

java - 使用 Java 的 AWS ElastiCache Redis

amazon-web-services - AWS X-Ray为什么不显示错误?

amazon-web-services - 是否可以使用基于标签的 AWS Lambda 列出存储桶?

python - 使用列表列表过滤列表列表

python - 使用 stats.exponweib.fit 在 python 中拟合威 bool 分布

python - 获取AWS EC2特定标签/值组合+实例ID

amazon-web-services - 在 aws cloudformation 模板中的 If 条件内使用 importValue

python - 如何使用 boto3 send_email 或 send_raw_email 发送 HTML 文本和附件?