Solved

Environment Set Up - Installing the Cognite SDK package

  • 25 January 2024
  • 2 replies
  • 104 views

Badge +6

I am able to run the code in the given Google Colab sheet. But when I am running the same code in my IDE (Spyder or Jupyter),  I am facing Cognite Connection Error in step 3.

Error message:


  File ~\Python Projects\myenv\Lib\site-packages\urllib3\connectionpool.py:467 in _make_request
    self._validate_conn(conn)

  File ~\Python Projects\myenv\Lib\site-packages\urllib3\connectionpool.py:1096 in _validate_conn
    conn.connect()

  File ~\Python Projects\myenv\Lib\site-packages\urllib3\connection.py:642 in connect
    sock_and_verified = _ssl_wrap_socket_and_match_hostname(

  File ~\Python Projects\myenv\Lib\site-packages\urllib3\connection.py:782 in _ssl_wrap_socket_and_match_hostname
    ssl_sock = ssl_wrap_socket(

  File ~\Python Projects\myenv\Lib\site-packages\urllib3\util\ssl_.py:470 in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls, server_hostname)

  File ~\Python Projects\myenv\Lib\site-packages\urllib3\util\ssl_.py:514 in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)

  File ~\AppData\Local\Programs\Python\Python312\Lib\ssl.py:455 in wrap_socket
    return self.sslsocket_class._create(

  File ~\AppData\Local\Programs\Python\Python312\Lib\ssl.py:1046 in _create
    self.do_handshake()

  File ~\AppData\Local\Programs\Python\Python312\Lib\ssl.py:1321 in do_handshake
    self._sslobj.do_handshake()

SSLError: [SSL: UNSAFE_LEGACY_RENEGOTIATION_DISABLED] unsafe legacy renegotiation disabled (_ssl.c:1000)


During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File ~\Python Projects\myenv\Lib\site-packages\requests\adapters.py:486 in send
    resp = conn.urlopen(

  File ~\Python Projects\myenv\Lib\site-packages\urllib3\connectionpool.py:844 in urlopen
    retries = retries.increment(

  File ~\Python Projects\myenv\Lib\site-packages\urllib3\util\retry.py:445 in increment
    raise reraise(type(error), error, _stacktrace)

  File ~\Python Projects\myenv\Lib\site-packages\urllib3\util\util.py:39 in reraise
    raise value

  File ~\Python Projects\myenv\Lib\site-packages\urllib3\connectionpool.py:790 in urlopen
    response = self._make_request(

  File ~\Python Projects\myenv\Lib\site-packages\urllib3\connectionpool.py:491 in _make_request
    raise new_e

SSLError: [SSL: UNSAFE_LEGACY_RENEGOTIATION_DISABLED] unsafe legacy renegotiation disabled (_ssl.c:1000)


During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File ~\Python Projects\myenv\Lib\site-packages\cognite\client\_http_client.py:151 in _do_request
    res = self.session.request(method=method, url=url, **kwargs)

  File ~\Python Projects\myenv\Lib\site-packages\requests\sessions.py:589 in request
    resp = self.send(prep, **send_kwargs)

  File ~\Python Projects\myenv\Lib\site-packages\requests\sessions.py:703 in send
    r = adapter.send(request, **kwargs)

  File ~\Python Projects\myenv\Lib\site-packages\requests\adapters.py:530 in send
    raise SSLError(e, request=request)

SSLError: [SSL: UNSAFE_LEGACY_RENEGOTIATION_DISABLED] unsafe legacy renegotiation disabled (_ssl.c:1000)


The above exception was the direct cause of the following exception:

Traceback (most recent call last):

  File ~\Python Projects\myenv\Lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec
    exec(code, globals, locals)

  File c:\users\ravi.bhagwat\testpy.py:29
    token_info = client.iam.token.inspect()  # 'iam' stands for: Identity and Access Management

  File ~\Python Projects\myenv\Lib\site-packages\cognite\client\_api\iam.py:406 in inspect
    return TokenInspection.load(self._get("/api/v1/token/inspect").json(), self._cognite_client)

  File ~\Python Projects\myenv\Lib\site-packages\cognite\client\_api_client.py:149 in _get
    return self._do_request("GET", url_path, params=params, headers=headers, timeout=self._config.timeout)

  File ~\Python Projects\myenv\Lib\site-packages\cognite\client\_api_client.py:217 in _do_request
    res = self._http_client_with_retry.request(method=method, url=full_url, **kwargs)

  File ~\Python Projects\myenv\Lib\site-packages\cognite\client\_http_client.py:135 in request
    raise e

  File ~\Python Projects\myenv\Lib\site-packages\cognite\client\_http_client.py:115 in request
    res = self._do_request(method=method, url=url, **kwargs)

  File ~\Python Projects\myenv\Lib\site-packages\cognite\client\_http_client.py:169 in _do_request
    raise CogniteConnectionError from e

CogniteConnectionError

icon

Best answer by DeelakaCS 8 February 2024, 14:47

View original

2 replies

Userlevel 4
Badge +2

Hi @RaviBhagwat,

I have created a support ticket. The team will look into this and follow up on it.

Br,
Dilini

Userlevel 1
Badge

Resolution Summary
 
Issue: User having an issue when using Python SDK notebook.
SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1000)
 
Assumed that company network setting might blocking API calls to CDF endpoint.
Asked the user to try SDK notebook using a personal laptop and personal network.
The user informed that the SDK notebook works on personal laptop.
 
Solution: The issue was resolved by installing pyopenssl using "pip install pyOpenSSL"

Reply