我使用boto3连接到AWS的代码遇到错误。该错误仅在昨天下午开始,在上一次我没有收到错误和第一次我得到错误之间,我看不到任何变化。
错误是:
botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL:
在.aws / config中,我有:
$ cat ~/.aws/config [default] region=us-east-1
这是我所知道的:
我不认为在上一次有效与第一次无效之间没有改变任何会影响此效果的内容。看来我不得不不得不改变某些特定于AWS的配置或某些低级库,而我没有进行任何此类更改。我与一位同事交谈了30-45分钟,当我返回并在我离开的地方接起电话时,问题就第一次出现了。
关于解决此问题有任何想法或想法吗?
完整的异常转储如下。
$ python Python 2.7.10 (default, Jul 14 2015, 19:46:27) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import boto3 >>> boto3.client('ec2').describe_regions() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Library/Python/2.7/site-packages/botocore/client.py", line 200, in _api_call return self._make_api_call(operation_name, kwargs) File "/Library/Python/2.7/site-packages/botocore/client.py", line 244, in _make_api_call operation_model, request_dict) File "/Library/Python/2.7/site-packages/botocore/endpoint.py", line 173, in make_request return self._send_request(request_dict, operation_model) File "/Library/Python/2.7/site-packages/botocore/endpoint.py", line 203, in _send_request success_response, exception): File "/Library/Python/2.7/site-packages/botocore/endpoint.py", line 267, in _needs_retry caught_exception=caught_exception) File "/Library/Python/2.7/site-packages/botocore/hooks.py", line 226, in emit return self._emit(event_name, kwargs) File "/Library/Python/2.7/site-packages/botocore/hooks.py", line 209, in _emit response = handler(**kwargs) File "/Library/Python/2.7/site-packages/botocore/retryhandler.py", line 183, in __call__ if self._checker(attempts, response, caught_exception): File "/Library/Python/2.7/site-packages/botocore/retryhandler.py", line 250, in __call__ caught_exception) File "/Library/Python/2.7/site-packages/botocore/retryhandler.py", line 273, in _should_retry return self._checker(attempt_number, response, caught_exception) File "/Library/Python/2.7/site-packages/botocore/retryhandler.py", line 313, in __call__ caught_exception) File "/Library/Python/2.7/site-packages/botocore/retryhandler.py", line 222, in __call__ return self._check_caught_exception(attempt_number, caught_exception) File "/Library/Python/2.7/site-packages/botocore/retryhandler.py", line 355, in _check_caught_exception raise caught_exception botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "https://ec2.us-east-1.amazonaws.com/"
问题解决了。事实证明,独立于boto相关内容的几个看似无关的动作导致HTTP_PROXY和HTTPS_PROXY环境变量的设置不正确,从而破坏了boto3和aws cli下的botocore调用。删除两个环境变量均解决了该问题。
我将其遗漏,因为我发现很难找到任何指向此错误的可能原因。可能会节省别人拉过我的头发。