简体   繁体   English

使用python3导入boto3时出现属性错误

[英]Attribute error while importing boto3 using python3

I'm trying to use aws rekognition client using boto3 on my raspberry pi, have successfully installed aws cli and have configured it also.我正在尝试在我的树莓派上使用 boto3 使用 aws rekognition 客户端,已成功安装 aws cli 并对其进行了配置。 But when i execute the following code avaialbe in aws blog,但是当我在 aws 博客中执行以下代码时,

import boto3

def detect_labels_local_file(photo):


    client=boto3.client('rekognition')

    with open(photo, 'rb') as image:
        response = client.detect_labels(Image={'Bytes': image.read()})

    print('Detected labels in ' + photo)    
    for label in response['Labels']:
        print (label['Name'] + ' : ' + str(label['Confidence']))

    return len(response['Labels'])

def main():
    photo='photo'

    label_count=detect_labels_local_file(photo)
    print("Labels detected: " + str(label_count))


if __name__ == "__main__":
    main()

I get the following error:我收到以下错误:

  import boto3
  File "/usr/local/lib/python3.7/dist-packages/boto3/__init__.py", line 16, in <module>
    from boto3.session import Session
  File "/usr/local/lib/python3.7/dist-packages/boto3/session.py", line 17, in <module>
    import botocore.session
  File "/home/pi/.local/lib/python3.7/site-packages/botocore/session.py", line 28, in <module>
    import botocore.configloader
  File "/home/pi/.local/lib/python3.7/site-packages/botocore/configloader.py", line 19, in <module>
    from botocore.compat import six
  File "/home/pi/.local/lib/python3.7/site-packages/botocore/compat.py", line 25, in <module>
    from botocore.exceptions import MD5UnavailableError
  File "/home/pi/.local/lib/python3.7/site-packages/botocore/exceptions.py", line 99, in <module>
    class SSLError(ConnectionError, requests.exceptions.SSLError):
AttributeError: module 'botocore.vendored.requests' has no attribute 'exceptions

Please help me solve it, or tell me what i'm doing wrong.请帮我解决它,或者告诉我我做错了什么。 Note: I'm using python 3.7.3.注意:我使用的是 python 3.7.3。

This blog post should help to explain it.这篇博文应该有助于解释它。

You will now need to include this dependency yourself as it is no longer bundled with boto3.您现在需要自己包含此依赖项,因为它不再与 boto3 捆绑在一起。

For you Raspberry Pi running the following should be sufficient对于运行以下内容的 Raspberry Pi 来说应该足够了

pip install requests

Then add import requests to your py script然后将import requests添加到您的 py 脚本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尝试在 VSCode 中使用 boto3 python 3.7 创建 lambda 函数时出现“AttributeError: module &#39;boto3&#39; has no attribute &#39;client&#39;”错误 - "AttributeError: module 'boto3' has no attribute 'client'" error while trying to create lambda function using boto3 python 3.7 in VSCode 在python中使用boto3服务员时出错 - Getting an error while using the boto3 waiter in python 带有 boto3 的 Python3 语法 - Python3 Syntax with boto3 Python3 Boto3对WAV的响应 - Python3 boto3 response to wav 使用 boto3 在 python 中使用另一个现有表的结构创建 DynamoDB 表时出错 - Error while creating DynamoDB table using another existing table's structure in python using boto3 python:在 boto3 1.7.21 中使用 bucket.objects.filter(Prefi=myPrefixString) 时出现 InvalidToken 错误 - python: I get InvalidToken error while using bucket.objects.filter(Prefi=myPrefixString) in boto3 1.7.21 使用boto3和python flask将CSV文件上传到S3存储桶时出现错误500 - Error 500 while Uploading CSV file to S3 bucket using boto3 and python flask 在python中导入boto3错误 - Import boto3 error in python 尝试使用 boto3 为 EMR 获取实例类型和计数时出错 - Error while trying to get INSTANCETYPE AND COUNT using boto3 for EMR 使用 boto3 客户端更新 ECR 权限时出错 - Error while updating ECR permission using boto3 client
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM