Black Lives Matter. Please consider donating to Black Girls Code today.
https://www.blackgirlscode.com

Plotly Error: Sign in failed while trying to upload interactive plot to my plotly account

Hello,

I have created an offline choropleth interactive map based plot which I would like to embed in a Powerpoint presentation. I have a local html file for the interactive plot. Next I tried to sign in to my plotly online account to store / export the plot in my plotly account using chartstudio. However I keep getting a ‘sign in failed error’.

The code for my graph is:

fig = ff.create_choropleth(fips=ACPC_counties, values=ACPC_count, scope = [‘MI’],
county_outline={‘color’: ‘rgb(255,255,255)’, ‘width’: 0.5},
legend_title=‘ACPC enrollment count per county’, colorscale = colorscale, binning_endpoints=endpts)

fig.update_layout(hovermode=“closest”)
py.offline.plot(fig, filename=‘choropleth_ACPC’,
include_plotlyjs=‘https://cdn.plot.ly/plotly-1.42.3.min.js’)

This generates a local html file. Now when I try to upload it to my plotly account using the following code

import chart_studio.plotly as py

py.sign_in(username, api_key)

where username is my username and api_key is the api_key I generated from the online plotly account I get the following error:


SysCallError                              Traceback (most recent call last)
~\AppData\Local\Continuum\anaconda3\lib\site-packages\urllib3\contrib\pyopenssl.py in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname)
    484             try:
--> 485                 cnx.do_handshake()
    486             except OpenSSL.SSL.WantReadError:

~\AppData\Local\Continuum\anaconda3\lib\site-packages\OpenSSL\SSL.py in do_handshake(self)
   1933         result = _lib.SSL_do_handshake(self._ssl)
-> 1934         self._raise_ssl_error(self._ssl, result)
   1935 

~\AppData\Local\Continuum\anaconda3\lib\site-packages\OpenSSL\SSL.py in _raise_ssl_error(self, ssl, result)
   1662                     if errno != 0:
-> 1663                         raise SysCallError(errno, errorcode.get(errno))
   1664                 raise SysCallError(-1, "Unexpected EOF")

SysCallError: (10054, 'WSAECONNRESET')

During handling of the above exception, another exception occurred:

SSLError                                  Traceback (most recent call last)
~\AppData\Local\Continuum\anaconda3\lib\site-packages\urllib3\connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    671                 headers=headers,
--> 672                 chunked=chunked,
    673             )

~\AppData\Local\Continuum\anaconda3\lib\site-packages\urllib3\connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    375         try:
--> 376             self._validate_conn(conn)
    377         except (SocketTimeout, BaseSSLError) as e:

~\AppData\Local\Continuum\anaconda3\lib\site-packages\urllib3\connectionpool.py in _validate_conn(self, conn)
    993         if not getattr(conn, "sock", None):  # AppEngine might not have  `.sock`
--> 994             conn.connect()
    995 

~\AppData\Local\Continuum\anaconda3\lib\site-packages\urllib3\connection.py in connect(self)
    359             server_hostname=server_hostname,
--> 360             ssl_context=context,
    361         )

~\AppData\Local\Continuum\anaconda3\lib\site-packages\urllib3\util\ssl_.py in ssl_wrap_socket(sock, keyfile, certfile, cert_reqs, ca_certs, server_hostname, ssl_version, ciphers, ssl_context, ca_cert_dir, key_password)
    369         if HAS_SNI and server_hostname is not None:
--> 370             return context.wrap_socket(sock, server_hostname=server_hostname)
    371 

~\AppData\Local\Continuum\anaconda3\lib\site-packages\urllib3\contrib\pyopenssl.py in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname)
    490             except OpenSSL.SSL.Error as e:
--> 491                 raise ssl.SSLError("bad handshake: %r" % e)
    492             break

SSLError: ("bad handshake: SysCallError(10054, 'WSAECONNRESET')",)

During handling of the above exception, another exception occurred:

MaxRetryError                             Traceback (most recent call last)
~\AppData\Local\Continuum\anaconda3\lib\site-packages\requests\adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    448                     retries=self.max_retries,
--> 449                     timeout=timeout
    450                 )

~\AppData\Local\Continuum\anaconda3\lib\site-packages\urllib3\connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    719             retries = retries.increment(
--> 720                 method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
    721             )

~\AppData\Local\Continuum\anaconda3\lib\site-packages\urllib3\util\retry.py in increment(self, method, url, response, error, _pool, _stacktrace)
    435         if new_retry.is_exhausted():
--> 436             raise MaxRetryError(_pool, url, error or ResponseError(cause))
    437 

MaxRetryError: HTTPSConnectionPool(host='api.plotly.com', port=443): Max retries exceeded with url: /v2/users/current (Caused by SSLError(SSLError("bad handshake: SysCallError(10054, 'WSAECONNRESET')")))

During handling of the above exception, another exception occurred:

SSLError                                  Traceback (most recent call last)
~\AppData\Local\Continuum\anaconda3\lib\site-packages\chart_studio\api\v2\utils.py in request(method, url, **kwargs)
    171     try:
--> 172         response = requests.request(method, url, **kwargs)
    173     except RequestException as e:

~\AppData\Local\Continuum\anaconda3\lib\site-packages\requests\api.py in request(method, url, **kwargs)
     60     with sessions.Session() as session:
---> 61         return session.request(method=method, url=url, **kwargs)
     62 

~\AppData\Local\Continuum\anaconda3\lib\site-packages\requests\sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
    529         send_kwargs.update(settings)
--> 530         resp = self.send(prep, **send_kwargs)
    531 

~\AppData\Local\Continuum\anaconda3\lib\site-packages\requests\sessions.py in send(self, request, **kwargs)
    642         # Send the request
--> 643         r = adapter.send(request, **kwargs)
    644 

~\AppData\Local\Continuum\anaconda3\lib\site-packages\requests\adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    513                 # This branch is for urllib3 v1.22 and later.
--> 514                 raise SSLError(e, request=request)
    515 

SSLError: HTTPSConnectionPool(host='api.plotly.com', port=443): Max retries exceeded with url: /v2/users/current (Caused by SSLError(SSLError("bad handshake: SysCallError(10054, 'WSAECONNRESET')")))

During handling of the above exception, another exception occurred:

PlotlyRequestError                        Traceback (most recent call last)
~\AppData\Local\Continuum\anaconda3\lib\site-packages\chart_studio\plotly\plotly.py in sign_in(username, api_key, **kwargs)
     64         # with the given, username, api_key, and plotly_api_domain.
---> 65         v2.users.current()
     66     except exceptions.PlotlyRequestError:

~\AppData\Local\Continuum\anaconda3\lib\site-packages\chart_studio\api\v2\users.py in current()
     16     url = build_url(RESOURCE, route="current")
---> 17     return request("get", url)

~\AppData\Local\Continuum\anaconda3\lib\site-packages\retrying.py in wrapped_f(*args, **kw)
     48             def wrapped_f(*args, **kw):
---> 49                 return Retrying(*dargs, **dkw).call(f, *args, **kw)
     50 

~\AppData\Local\Continuum\anaconda3\lib\site-packages\retrying.py in call(self, fn, *args, **kwargs)
    205             if not self.should_reject(attempt):
--> 206                 return attempt.get(self._wrap_exception)
    207 

~\AppData\Local\Continuum\anaconda3\lib\site-packages\retrying.py in get(self, wrap_exception)
    246             else:
--> 247                 six.reraise(self.value[0], self.value[1], self.value[2])
    248         else:

~\AppData\Local\Continuum\anaconda3\lib\site-packages\six.py in reraise(tp, value, tb)
    702                 raise value.with_traceback(tb)
--> 703             raise value
    704         finally:

~\AppData\Local\Continuum\anaconda3\lib\site-packages\retrying.py in call(self, fn, *args, **kwargs)
    199             try:
--> 200                 attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
    201             except:

~\AppData\Local\Continuum\anaconda3\lib\site-packages\chart_studio\api\v2\utils.py in request(method, url, **kwargs)
    178         content = response.content if response else "No content"
--> 179         raise exceptions.PlotlyRequestError(message, status_code, content)
    180     validate_response(response)

PlotlyRequestError: No message

During handling of the above exception, another exception occurred:

PlotlyError                               Traceback (most recent call last)
<ipython-input-169-673c292c8a83> in <module>
----> 1 ply.sign_in(username, api_key)

~\AppData\Local\Continuum\anaconda3\lib\site-packages\chart_studio\plotly\plotly.py in sign_in(username, api_key, **kwargs)
     65         v2.users.current()
     66     except exceptions.PlotlyRequestError:
---> 67         raise _plotly_utils.exceptions.PlotlyError("Sign in failed.")
     68 
     69 

PlotlyError: Sign in failed.

How do I fix this? I made sure my ~/.plotly/.credentials file has the correct username and api-key.

Any help is appreciated. Thanks a lot.

This looks like a connection error rather than a Plotly-related error…

1 Like

Thanks for your reply.

Hi,

Is there a way to specify the port? In the error it says:

SSLError: HTTPSConnectionPool(host=‘api.plotly.com’, port=443): Max retries exceeded with url: /v2/users/current (Caused by SSLError(SSLError(“bad handshake: SysCallError(10054, ‘WSAECONNRESET’)”)))

I would like to use a different port. I can’t find any documentation that would help with this.