尝试从s3下载数据时发生错误

时间:2018-11-15 09:22:52

标签: python python-3.x amazon-s3 boto3

它是完整日志

  File "/home/workspace/viv_data_handler/s3manager/s3_downloader.py", line 18, in download_file
    self.resource.meta.client.download_file(bucket, key, dest)
  File "/usr/local/lib/python3.5/site-packages/boto3/s3/inject.py", line 172, in download_file
    extra_args=ExtraArgs, callback=Callback)
  File "/usr/local/lib/python3.5/site-packages/boto3/s3/transfer.py", line 307, in download_file
    future.result()
  File "/usr/local/lib/python3.5/site-packages/s3transfer/futures.py", line 73, in result
    return self._coordinator.result()
  File "/usr/local/lib/python3.5/site-packages/s3transfer/futures.py", line 233, in result
    raise self._exception
  File "/usr/local/lib/python3.5/site-packages/s3transfer/tasks.py", line 255, in _main
    self._submit(transfer_future=transfer_future, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/s3transfer/download.py", line 353, in _submit
    **transfer_future.meta.call_args.extra_args
  File "/usr/local/lib/python3.5/site-packages/botocore/client.py", line 314, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/usr/local/lib/python3.5/site-packages/botocore/client.py", line 599, in _make_api_call
    operation_model, request_dict)
  File "/usr/local/lib/python3.5/site-packages/botocore/endpoint.py", line 148, in make_request
    return self._send_request(request_dict, operation_model)
  File "/usr/local/lib/python3.5/site-packages/botocore/endpoint.py", line 177, in _send_request
    success_response, exception):
  File "/usr/local/lib/python3.5/site-packages/botocore/endpoint.py", line 273, in _needs_retry
    caught_exception=caught_exception, request_dict=request_dict)
  File "/usr/local/lib/python3.5/site-packages/botocore/hooks.py", line 227, in emit
    return self._emit(event_name, kwargs)
  File "/usr/local/lib/python3.5/site-packages/botocore/hooks.py", line 210, in _emit
    response = handler(**kwargs)
  File "/usr/local/lib/python3.5/site-packages/botocore/retryhandler.py", line 183, in __call__
    if self._checker(attempts, response, caught_exception):
  File "/usr/local/lib/python3.5/site-packages/botocore/retryhandler.py", line 251, in __call__
    caught_exception)
  File "/usr/local/lib/python3.5/site-packages/botocore/retryhandler.py", line 277, in _should_retry
    return self._checker(attempt_number, response, caught_exception)
  File "/usr/local/lib/python3.5/site-packages/botocore/retryhandler.py", line 317, in __call__
    caught_exception)
  File "/usr/local/lib/python3.5/site-packages/botocore/retryhandler.py", line 223, in __call__
    attempt_number, caught_exception)
  File "/usr/local/lib/python3.5/site-packages/botocore/retryhandler.py", line 359, in _check_caught_exception
    raise caught_exception
  File "/usr/local/lib/python3.5/site-packages/botocore/endpoint.py", line 222, in _get_response
    proxies=self.proxies, timeout=self.timeout)
  File "/usr/local/lib/python3.5/site-packages/botocore/vendored/requests/sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/botocore/vendored/requests/adapters.py", line 431, in send
    raise SSLError(e, request=request)
botocore.vendored.requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:719)

您好,我正在使用S3开发程序,但是有问题

botocore.vendored.requests.exceptions.SSLError错误,当我尝试使用Boto3从S3下载数据时出现

当另一台服务器使用相同的代码时,它可以工作。并且在同一台服务器(boto3发生故障的服务器)上使用aws cli时可以使用。

我不知道该怎么解决。

请帮助我。谢谢。

1 个答案:

答案 0 :(得分:0)

对于任何boto3.Session.client或boto3.Session.resource对象,您可以传递verify=False参数以跳过SSL证书验证。例如,当您创建客户端或资源时,请执行以下操作:

import boto3

boto3_session = boto3.Session(profile_name=some_profile_you_configured)

s3_resource = boto3_session.resource(service_name='s3', verify=False)
s3_client = boto3_session.client(service_name='s3', verify=False)

[insert your code here using the s3_resource or s3_client objects]

boto3 documentation是您最好的朋友。