Python3 连接雪花时出错:snowflake.connector.errors.OperationalError::Failed to execute:'SSLSocket' object has no attribute 'conn

vis*_*wal 2 python-3.x snowflake-cloud-data-platform

最新的雪花连接器似乎存在一些问题。我正在尝试在 Ubuntu 操作系统上安装它并尝试连接到雪花,但它给出了错误 AttributeError: 'SSLSocket' object has no attribute 'connection'

以下是环境详细信息:--

我使用的是 python3.5.2 版本,ubuntu(Ubuntu 16.04.6 LTS)并且还安装了最新的雪花 python 连接器 2.2.6。
这是 pip3 list asn1crypto 1.3.0 awscli 1.11.13 azure-common 1.1.25 azure-storage-blob 2.1.0 azure-storage-common 2.1.0 flasher 1.3 boto3 1.13.7 certifocore 1.13.7 certifocore 1.13.7 certifcore 2 的输出5.1 cffi 1.13.2 chardet 2.3.0 cloud-init 19.4 colorama 0.3.7 command-not-found 0.3 configobj 5.0.6 密码学2.9.2 docutils 0.12 hibagent 1.0.1 idna 2.0 ijson 2.20p2.json 2.01.json 2.20.01 1.10 jsonpointer 1.9 语言选择器 0。1 MarkupSafe 0.23 oauthlib 1.0.3 oscrypto 1.2.0 Pillow 3.1.2 pip 20.1 Prettytable 0.7.2 pyasn1 0.1.9 pycparser 2.20 pycryptodomex 3.9.7 Pycurl 7.4.20py10.ssl.7.420.ssl.1.2.0.ssl.3.1.2.0.1.2.0.0.1.3.0.1.30py10.ssl.20.1.2.0.1.2.0.1.2.0.1.2.0.1.2.1.2.0.1.0.1.1.1.9 pycparser 3.0.1 python-apt 1.1.0b1+ubuntu0.16.4.8 python-dateutil 2.4.2 python-debian 0.1.27 python-systemd 231 pytz 2020.1 PyYAML 3.11 请求 2.9.1 罗马 2.0.0 .0s3333 .rsa .3 setuptools 46.2.0 6 1.10.0 snowflake-connector-python 2.2.6 ssh-import-id 5.5 ufw 0.35 unattended-upgrades 0.1 urllib3 1.25.9 wheel 0.34.2

我正在使用雪花文档https://docs.snowflake.com/en/user-guide/python-connector-install.html#step-2-verify-your-installation 中提到的示例 python 代码

这是错误:-

Traceback (most recent call last):
  File "/home/ubuntu/.local/lib/python3.5/site-packages/snowflake/connector/network.py", line 799, in _request_exec
    auth=SnowflakeAuth(token),
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 480, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 588, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 376, in send
    timeout=timeout
  File "/home/ubuntu/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 677, in urlopen
    chunked=chunked,
  File "/home/ubuntu/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 381, in _make_request
    self._validate_conn(conn)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 976, in _validate_conn
    conn.connect()
  File "/home/ubuntu/.local/lib/python3.5/site-packages/urllib3/connection.py", line 370, in connect
    ssl_context=context,
  File "/home/ubuntu/.local/lib/python3.5/site-packages/snowflake/connector/ssl_wrap_socket.py", line 411, in ssl_wrap_socket_with_ocsp
    ).validate(server_hostname, ret.connection)
AttributeError: 'SSLSocket' object has no attribute 'connection'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ubuntu/.local/lib/python3.5/site-packages/snowflake/connector/network.py", line 649, in _request_exec_wrapper
    **kwargs)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/snowflake/connector/network.py", line 892, in _request_exec
    raise RetryRequest(err)
snowflake.connector.network.RetryRequest: 'SSLSocket' object has no attribute 'connection'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ubuntu/infaagent/apps/Data_Integration_Server/data/Scripts/test1.py", line 9, in <module>
    account='qsdunitydev'
  File "/home/ubuntu/.local/lib/python3.5/site-packages/snowflake/connector/__init__.py", line 53, in Connect
    return SnowflakeConnection(**kwargs)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/snowflake/connector/connection.py", line 189, in __init__
    self.connect(**kwargs)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/snowflake/connector/connection.py", line 493, in connect
    self.__open_connection()
  File "/home/ubuntu/.local/lib/python3.5/site-packages/snowflake/connector/connection.py", line 710, in __open_connection
    self.__authenticate(auth_instance)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/snowflake/connector/connection.py", line 964, in __authenticate
    session_parameters=self._session_parameters,
  File "/home/ubuntu/.local/lib/python3.5/site-packages/snowflake/connector/auth.py", line 216, in authenticate
    socket_timeout=self._rest._connection.login_timeout)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/snowflake/connector/network.py", line 530, in _post_request
    _include_retry_params=_include_retry_params)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/snowflake/connector/network.py", line 609, in fetch
    **kwargs)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/snowflake/connector/network.py", line 692, in _request_exec_wrapper
    conn, full_url, cause)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/snowflake/connector/network.py", line 722, in handle_invalid_certificate_error
    u'errno': ER_FAILED_TO_REQUEST,
  File "/home/ubuntu/.local/lib/python3.5/site-packages/snowflake/connector/errors.py", line 100, in errorhandler_wrapper
    connection.errorhandler(connection, cursor, errorclass, errorvalue)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/snowflake/connector/errors.py", line 73, in default_errorhandler
    done_format_msg=errorvalue.get(u'done_format_msg'))
snowflake.connector.errors.OperationalError: 250003: Failed to execute request: 'SSLSocket' object has no attribute 'connection'
Run Code Online (Sandbox Code Playgroud)

小智 10

您可以运行以下命令来更新请求,然后尝试

pip3 安装请求==2.23.0

此外,如果可能,请将 Python 版本升级到 3.7 并检查问题是否仍然存在。