[英]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.