ImportError: cannot import name dump_publickey

2019-07-31 08:00发布

Successfully installed pip install --upgrade snowflake-connector-python , but i'm unable to print snowflake version. Don't know what could be the issue. Followed steps provided in below link.

https://docs.snowflake.net/manuals/user-guide/python-connector-install.html#step-2-verify-your-installation

import snowflake.connector

    # Gets the version
    ctx = snowflake.connector.connect(
        user='<your_user_name>',
        password='<your_password>',
        account='<your_account_name>'
        )
    cs = ctx.cursor()
    try:
        cs.execute("SELECT current_version()")
        one_row = cs.fetchone()
        print(one_row[0])
    finally:
        cs.close()
    ctx.close()

Traceback (most recent call last):
  File "validate.py", line 7, in <module>
    account='abc123'
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/snowflake/connector/__init__.py", line 32, in Connect
    return SnowflakeConnection(**kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/snowflake/connector/connection.py", line 147, in __init__
    self.connect(**kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/snowflake/connector/connection.py", line 355, in connect
    self.__open_connection()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/snowflake/connector/connection.py", line 548, in __open_connection
    self.__authenticate(auth_instance)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/snowflake/connector/connection.py", line 771, in __authenticate
    session_parameters=self._session_parameters,
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/snowflake/connector/auth.py", line 214, in authenticate
    socket_timeout=self._rest._connection.login_timeout)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/snowflake/connector/network.py", line 529, in _post_request
    _include_retry_params=_include_retry_params)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/snowflake/connector/network.py", line 618, in fetch
    **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/snowflake/connector/network.py", line 695, in _request_exec_wrapper
    raise e
ImportError: cannot import name dump_publickey

Can anyone help me please ?

LOGS:

INFO:snowflake.connector.connection:Snowflake Connector for Python Version: 1.6.11, Python Version: 2.7.14, Platform: Darwin-16.7.0-x86_64-i386-64bit
DEBUG:snowflake.connector.connection:connect
DEBUG:snowflake.connector.connection:__config
DEBUG:snowflake.connector.converter:use_sfbinaryformat: False, use_numpy: False
DEBUG:snowflake.connector.connection:REST API object was created: account_name.snowflakecomputing.com:443, proxy=None:None, proxy_user=None
DEBUG:snowflake.connector.auth:authenticate
DEBUG:snowflake.connector.auth:assertion content: *********
DEBUG:snowflake.connector.auth:account=account_name, user=user_name, database=None, schema=None, warehouse=None, role=None, request_id=29f36950-7763-4cee-ab48-bbe3716ca916
DEBUG:snowflake.connector.auth:body['data']: {u'CLIENT_APP_VERSION': u'1.6.11', u'CLIENT_APP_ID': u'PythonConnector', u'CLIENT_ENVIRONMENT': {u'PYTHON_VERSION': u'2.7.14', u'APPLICATION': u'PythonConnector', u'OS_VERSION': 'Darwin-16.7.0-x86_64-i386-64bit', u'PYTHON_COMPILER': 'GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)', u'OS': 'Darwin', u'PYTHON_RUNTIME': 'CPython'}, u'ACCOUNT_NAME': 'account_name', u'SVN_REVISION': None, u'LOGIN_NAME': 'user_name'}
DEBUG:botocore.vendored.requests.packages.urllib3.util.retry:Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None)
DEBUG:botocore.vendored.requests.packages.urllib3.util.retry:Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None)
DEBUG:snowflake.connector.network:Active requests sessions: 1, idle: 0
DEBUG:snowflake.connector.network:remaining request timeout: 120, retry cnt: 1
DEBUG:snowflake.connector.network:socket timeout: 60
INFO:botocore.vendored.requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): account_name.snowflakecomputing.com
DEBUG:snowflake.connector.network:Active requests sessions: 0, idle: 1

After debugging network.py, could make out that in def _request_exec , executing url https://account_name.snowflakecomputing.com:443/session/v1/login-request?request_id=9b1c563d-80a2-4608-af4d-8bc6b955ac70&request_guid=b88aba49-384a-409d-8387-4e4f934927ab in below block encounters error

raw_ret = session.request(
                method=method,
                url=full_url,
                proxies=proxies,
                headers=headers,
                data=input_data,
                timeout=socket_timeout,
                verify=True,
                stream=is_raw_binary,
                auth=SnowflakeAuth(token),
            )

Could be issue with any modules related to api/url-execution (requests,urllib3), just a guess. Can anyone help me ?

1条回答
Evening l夕情丶
2楼-- · 2019-07-31 08:38

I tried the code out and it works fine for me. Have you tried to enable logging? If yes can you share the logs? Also make sure you've got the account details right.

Just in case you don't have logging enabled it can be enabled by adding the following lines to your python script:

import logging
logging.basicConfig(
    filename='/tmp/snowflake_python_connector.log',
    level=logging.DEBUG)
查看更多
登录 后发表回答