通过命令行播种数据库时出现奇怪的SSL错误

时间:2017-08-30 21:33:28

标签: python ssl amazon-dynamodb

我有一个文件(它叫做conversation_template.py),我用它来播种我的DynamoDB数据库,直到最近才开始工作。

import boto3

dynamodb = boto3.resource('dynamodb', region_name='us-east-1')
table = dynamodb.Table('tablename')

data = {'<data_goes_here>'}


def add_to_table():
        table.put_item(Item=data)


add_to_table()

现在,当我在命令行中运行它时,我得到了这个:

Traceback (most recent call last):
  File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/vendored/requests/packages/urllib3/connectionpool.py", line 544, in urlopen
    body=body, headers=headers)
  File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/vendored/requests/packages/urllib3/connectionpool.py", line 341, in _make_request
    self._validate_conn(conn)
  File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/vendored/requests/packages/urllib3/connectionpool.py", line 761, in _validate_conn
    conn.connect()
  File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/vendored/requests/packages/urllib3/connection.py", line 238, in connect
    ssl_version=resolved_ssl_version)
  File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/vendored/requests/packages/urllib3/util/ssl_.py", line 279, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/ssl.py", line 401, in wrap_socket
    _context=self, _session=session)
  File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/ssl.py", line 808, in __init__
    self.do_handshake()
  File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/ssl.py", line 1061, in do_handshake
    self._sslobj.do_handshake()
  File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/ssl.py", line 683, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:748)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/vendored/requests/adapters.py", line 370, in send
    timeout=timeout
  File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/vendored/requests/packages/urllib3/connectionpool.py", line 574, in urlopen
    raise SSLError(e)
botocore.vendored.requests.packages.urllib3.exceptions.SSLError: [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:748)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "conversation_template.py", line 74, in <module>
    add_to_table()
  File "conversation_template.py", line 71, in add_to_table
    table.put_item(Item=episode)
  File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/boto3/resources/factory.py", line 520, in do_action
    response = action(self, *args, **kwargs)
  File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/boto3/resources/action.py", line 83, in __call__
    response = getattr(parent.meta.client, operation_name)(**params)
  File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/client.py", line 312, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/client.py", line 588, in _make_api_call
    operation_model, request_dict)
  File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/endpoint.py", line 141, in make_request
    return self._send_request(request_dict, operation_model)
  File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/endpoint.py", line 170, in _send_request
    success_response, exception):
  File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/endpoint.py", line 249, in _needs_retry
    caught_exception=caught_exception, request_dict=request_dict)
  File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/hooks.py", line 227, in emit
    return self._emit(event_name, kwargs)
  File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/hooks.py", line 210, in _emit
    response = handler(**kwargs)
  File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/retryhandler.py", line 183, in __call__
    if self._checker(attempts, response, caught_exception):
  File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/retryhandler.py", line 251, in __call__
    caught_exception)
  File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/retryhandler.py", line 277, in _should_retry
    return self._checker(attempt_number, response, caught_exception)
  File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/retryhandler.py", line 317, in __call__
    caught_exception)
  File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/retryhandler.py", line 223, in __call__
    attempt_number, caught_exception)
  File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/retryhandler.py", line 359, in _check_caught_exception
    raise caught_exception
  File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/endpoint.py", line 204, in _get_response
    proxies=self.proxies, timeout=self.timeout)
  File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/vendored/requests/sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "/Users/user/anaconda/envs/django_pocketcoach/lib/python3.6/site-packages/botocore/vendored/requests/adapters.py", line 431, in send
    raise SSLError(e, request=request)
botocore.vendored.requests.exceptions.SSLError: [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:748)

我试图弄清楚错误的来源,但我无法做到。即使错误消息也没有让我到处都是。

我得到了SSLError;协议未知。我发现这种类型的错误可能与我尝试连接到代理服务器有关,但我没有使用过,而且过去也没有这样做。

关于此错误可能来自哪里的任何想法?

1 个答案:

答案 0 :(得分:0)

最终有效的是退出当前的虚拟环境并运行:

pod 'CHTCollectionViewWaterfallLayout/Swift'

然后我再次进入虚拟环境并运行:

/Applications/Python\ 3.6/Install\ Certificates.command

修正了它。

我得到了一位朋友的帮助,他怀疑这可能与认证验证有关(与此相关:urllib and "SSL: CERTIFICATE_VERIFY_FAILED" Error)但仍不清楚为什么我没有收到“证书验证失败”错误。< / p>