I get an error when trying to execute a boto3 (python3) script in Amazon Workspaces (Windows Server) at work. Here are the script and steps.
Environment: Windows Server Datacenter
Script:
import boto3
s3 = boto3.resource('s3')
my_bucket = s3.Bucket('bucket_name')
for my_bucket_object in my_bucket.objects.all():
print(my_bucket_object)
Steps:
"botocore.exceptions.HTTPClientError: An HTTP Client raised an unhandled exception: check_hostname requires server_hostname"
I can execute AWS CLI commands in the workspace with no issues eg aws s3
commands all work properly. Any pointers appreciated.
I found a way to solve the issue
Replace
s3 = boto3.resource('s3')
with
s3 = boto3.resource('s3', config=Config(proxies={'https':'your_proxy_server_ip:3128'})})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.