I has been a long time user of plotly and dash, and was excited to try out the new JupyterDash package, but was unable to get it to work.
I am using a mac, with the following setup:
plotly = 4.9.0
jupyter_dash = 0.3.0
dash_core_components = 1.10.1
dash_html_components = 1.0.1
nodejs = v14.7.0
jupyterlab = 2.2.0
and have the jupyter-dash extension build.
I have tried to update my nodejs version and reinstall jupyter_dash without success. I don’t know what else I could try, so please help or let me know what other information I need to provide. Thanks in advance!
The code I am using are
import plotly.express as px
from jupyter_dash import JupyterDash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
# Load Data
df = px.data.tips()
# Build App
app = JupyterDash(__name__)
app.layout = html.Div([
html.H1("JupyterDash Demo"),
dcc.Graph(id='graph'),
html.Label([
"colorscale",
dcc.Dropdown(
id='colorscale-dropdown', clearable=False,
value='plasma', options=[
{'label': c, 'value': c}
for c in px.colors.named_colorscales()
])
]),
])
# Define callback to update graph
@app.callback(
Output('graph', 'figure'),
[Input("colorscale-dropdown", "value")]
)
def update_figure(colorscale):
return px.scatter(
df, x="total_bill", y="tip", color="size",
color_continuous_scale=colorscale,
render_mode="webgl", title="Tips"
)
# Run app and display result inline in the notebook
app.run_server(mode='inline')
and I got the following error message:
---------------------------------------------------------------------------
gaierror Traceback (most recent call last)
~/opt/anaconda3/lib/python3.7/site-packages/urllib3/connection.py in _new_conn(self)
156 conn = connection.create_connection(
--> 157 (self._dns_host, self.port), self.timeout, **extra_kw
158 )
~/opt/anaconda3/lib/python3.7/site-packages/urllib3/util/connection.py in create_connection(address, timeout, source_address, socket_options)
60
---> 61 for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
62 af, socktype, proto, canonname, sa = res
~/opt/anaconda3/lib/python3.7/socket.py in getaddrinfo(host, port, family, type, proto, flags)
751 addrlist = []
--> 752 for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
753 af, socktype, proto, canonname, sa = res
gaierror: [Errno 8] nodename nor servname provided, or not known
During handling of the above exception, another exception occurred:
NewConnectionError Traceback (most recent call last)
~/opt/anaconda3/lib/python3.7/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 )
~/opt/anaconda3/lib/python3.7/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
386 else:
--> 387 conn.request(method, url, **httplib_request_kw)
388
~/opt/anaconda3/lib/python3.7/http/client.py in request(self, method, url, body, headers, encode_chunked)
1251 """Send a complete request to the server."""
-> 1252 self._send_request(method, url, body, headers, encode_chunked)
1253
~/opt/anaconda3/lib/python3.7/http/client.py in _send_request(self, method, url, body, headers, encode_chunked)
1297 body = _encode(body, 'body')
-> 1298 self.endheaders(body, encode_chunked=encode_chunked)
1299
~/opt/anaconda3/lib/python3.7/http/client.py in endheaders(self, message_body, encode_chunked)
1246 raise CannotSendHeader()
-> 1247 self._send_output(message_body, encode_chunked=encode_chunked)
1248
~/opt/anaconda3/lib/python3.7/http/client.py in _send_output(self, message_body, encode_chunked)
1025 del self._buffer[:]
-> 1026 self.send(msg)
1027
~/opt/anaconda3/lib/python3.7/http/client.py in send(self, data)
965 if self.auto_open:
--> 966 self.connect()
967 else:
~/opt/anaconda3/lib/python3.7/site-packages/urllib3/connection.py in connect(self)
183 def connect(self):
--> 184 conn = self._new_conn()
185 self._prepare_conn(conn)
~/opt/anaconda3/lib/python3.7/site-packages/urllib3/connection.py in _new_conn(self)
168 raise NewConnectionError(
--> 169 self, "Failed to establish a new connection: %s" % e
170 )
NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7fa3adb64190>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known
During handling of the above exception, another exception occurred:
MaxRetryError Traceback (most recent call last)
~/opt/anaconda3/lib/python3.7/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
448 retries=self.max_retries,
--> 449 timeout=timeout
450 )
~/opt/anaconda3/lib/python3.7/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 )
~/opt/anaconda3/lib/python3.7/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: HTTPConnectionPool(host='x86_64-apple-darwin13.4.0', port=8050): Max retries exceeded with url: /_alive_98c9c9e9-2b68-4827-9e79-414975a06037 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fa3adb64190>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known'))
During handling of the above exception, another exception occurred:
ConnectionError Traceback (most recent call last)
<ipython-input-3-04de55125734> in <module>
33 )
34 # Run app and display result inline in the notebook
---> 35 app.run_server(mode='inline')
~/opt/anaconda3/lib/python3.7/site-packages/jupyter_dash/jupyter_app.py in run_server(self, mode, width, height, inline_exceptions, **kwargs)
317 )
318
--> 319 wait_for_app()
320
321 if JupyterDash._in_colab:
~/opt/anaconda3/lib/python3.7/site-packages/retrying.py in wrapped_f(*args, **kw)
47 @six.wraps(f)
48 def wrapped_f(*args, **kw):
---> 49 return Retrying(*dargs, **dkw).call(f, *args, **kw)
50
51 return wrapped_f
~/opt/anaconda3/lib/python3.7/site-packages/retrying.py in call(self, fn, *args, **kwargs)
210 if not self._wrap_exception and attempt.has_exception:
211 # get() on an attempt with an exception should cause it to be raised, but raise just in case
--> 212 raise attempt.get()
213 else:
214 raise RetryError(attempt)
~/opt/anaconda3/lib/python3.7/site-packages/retrying.py in get(self, wrap_exception)
245 raise RetryError(self)
246 else:
--> 247 six.reraise(self.value[0], self.value[1], self.value[2])
248 else:
249 return self.value
~/opt/anaconda3/lib/python3.7/site-packages/six.py in reraise(tp, value, tb)
701 if value.__traceback__ is not tb:
702 raise value.with_traceback(tb)
--> 703 raise value
704 finally:
705 value = None
~/opt/anaconda3/lib/python3.7/site-packages/retrying.py in call(self, fn, *args, **kwargs)
198 while True:
199 try:
--> 200 attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
201 except:
202 tb = sys.exc_info()
~/opt/anaconda3/lib/python3.7/site-packages/jupyter_dash/jupyter_app.py in wait_for_app()
305 )
306 def wait_for_app():
--> 307 res = requests.get(alive_url).content.decode()
308 if res != "Alive":
309 url = "http://{host}:{port}".format(
~/opt/anaconda3/lib/python3.7/site-packages/requests/api.py in get(url, params, **kwargs)
73
74 kwargs.setdefault('allow_redirects', True)
---> 75 return request('get', url, params=params, **kwargs)
76
77
~/opt/anaconda3/lib/python3.7/site-packages/requests/api.py in request(method, url, **kwargs)
58 # cases, and look like a memory leak in others.
59 with sessions.Session() as session:
---> 60 return session.request(method=method, url=url, **kwargs)
61
62
~/opt/anaconda3/lib/python3.7/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)
531 }
532 send_kwargs.update(settings)
--> 533 resp = self.send(prep, **send_kwargs)
534
535 return resp
~/opt/anaconda3/lib/python3.7/site-packages/requests/sessions.py in send(self, request, **kwargs)
644
645 # Send the request
--> 646 r = adapter.send(request, **kwargs)
647
648 # Total elapsed time of the request (approximately)
~/opt/anaconda3/lib/python3.7/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
514 raise SSLError(e, request=request)
515
--> 516 raise ConnectionError(e, request=request)
517
518 except ClosedPoolError as e:
ConnectionError: HTTPConnectionPool(host='x86_64-apple-darwin13.4.0', port=8050): Max retries exceeded with url: /_alive_98c9c9e9-2b68-4827-9e79-414975a06037 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fa3adb64190>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known'))
Exception in thread Thread-5:
Traceback (most recent call last):
File "/Users/tenggao/opt/anaconda3/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/Users/tenggao/opt/anaconda3/lib/python3.7/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/Users/tenggao/opt/anaconda3/lib/python3.7/site-packages/retrying.py", line 49, in wrapped_f
return Retrying(*dargs, **dkw).call(f, *args, **kw)
File "/Users/tenggao/opt/anaconda3/lib/python3.7/site-packages/retrying.py", line 212, in call
raise attempt.get()
File "/Users/tenggao/opt/anaconda3/lib/python3.7/site-packages/retrying.py", line 247, in get
six.reraise(self.value[0], self.value[1], self.value[2])
File "/Users/tenggao/opt/anaconda3/lib/python3.7/site-packages/six.py", line 703, in reraise
raise value
File "/Users/tenggao/opt/anaconda3/lib/python3.7/site-packages/retrying.py", line 200, in call
attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
File "/Users/tenggao/opt/anaconda3/lib/python3.7/site-packages/jupyter_dash/jupyter_app.py", line 289, in run
super_run_server(**kwargs)
File "/Users/tenggao/opt/anaconda3/lib/python3.7/site-packages/dash/dash.py", line 1615, in run_server
self.server.run(host=host, port=port, debug=debug, **flask_run_options)
File "/Users/tenggao/opt/anaconda3/lib/python3.7/site-packages/flask/app.py", line 990, in run
run_simple(host, port, self, **options)
File "/Users/tenggao/opt/anaconda3/lib/python3.7/site-packages/werkzeug/serving.py", line 1052, in run_simple
inner()
File "/Users/tenggao/opt/anaconda3/lib/python3.7/site-packages/werkzeug/serving.py", line 1005, in inner
fd=fd,
File "/Users/tenggao/opt/anaconda3/lib/python3.7/site-packages/werkzeug/serving.py", line 848, in make_server
host, port, app, request_handler, passthrough_errors, ssl_context, fd=fd
File "/Users/tenggao/opt/anaconda3/lib/python3.7/site-packages/werkzeug/serving.py", line 740, in __init__
HTTPServer.__init__(self, server_address, handler)
File "/Users/tenggao/opt/anaconda3/lib/python3.7/socketserver.py", line 452, in __init__
self.server_bind()
File "/Users/tenggao/opt/anaconda3/lib/python3.7/http/server.py", line 137, in server_bind
socketserver.TCPServer.server_bind(self)
File "/Users/tenggao/opt/anaconda3/lib/python3.7/socketserver.py", line 466, in server_bind
self.socket.bind(self.server_address)
socket.gaierror: [Errno 8] nodename nor servname provided, or not known