I am trying to get a simple dashboard up and running but I am running into an error:
The code:
import dash
app = dash.Dash()
app.layout = html.Div([
html.H1('Hi Dash'),
html.Div('Dash - a dashboard')
])
if __name__=='__main__':
app.run_server(port=4050)
I run this on a Jupyter Notebook and also on a VS code editor running python 3.9.12 on OpenSuse leap.
The error:
Dash is running on http://localhost.localdomain:4050/
Dash is running on http://localhost.localdomain:4050/
Dash is running on http://localhost.localdomain:4050/
Dash is running on http://localhost.localdomain:4050/
* Serving Flask app '__main__'
* Debug mode: off
Name or service not known
---------------------------------------------------------------------------
gaierror Traceback (most recent call last)
File ~/miniconda3/lib/python3.9/site-packages/werkzeug/serving.py:911, in prepare_socket(hostname, port)
910 try:
--> 911 s.bind(server_address)
912 except OSError as e:
gaierror: [Errno -2] Name or service not known
During handling of the above exception, another exception occurred:
SystemExit Traceback (most recent call last)
[... skipping hidden 1 frame]
Cell In [8], line 2
1 if __name__=='__main__':
----> 2 app.run_server(port=4050)
File ~/miniconda3/lib/python3.9/site-packages/dash/dash.py:2128, in Dash.run_server(self, *args, **kwargs)
2123 """`run_server` is a deprecated alias of `run` and may be removed in a
2124 future version. We recommend using `app.run` instead.
2125
2126 See `app.run` for usage information.
2127 """
-> 2128 self.run(*args, **kwargs)
File ~/miniconda3/lib/python3.9/site-packages/dash/dash.py:1961, in Dash.run(self, host, port, proxy, debug, dev_tools_ui, dev_tools_props_check, dev_tools_serve_dev_bundles, dev_tools_hot_reload, dev_tools_hot_reload_interval, dev_tools_hot_reload_watch_interval, dev_tools_hot_reload_max_retry, dev_tools_silence_routes_logging, dev_tools_prune_errors, **flask_run_options)
1959 extra_files.append(path)
-> 1961 self.server.run(host=host, port=port, debug=debug, **flask_run_options)
File ~/miniconda3/lib/python3.9/site-packages/flask/app.py:1188, in Flask.run(self, host, port, debug, load_dotenv, **options)
1187 try:
-> 1188 run_simple(t.cast(str, host), port, self, **options)
1189 finally:
1190 # reset the first request information if the development server
1191 # reset normally. This makes it possible to restart the server
1192 # without reloader and that stuff from an interactive shell.
File ~/miniconda3/lib/python3.9/site-packages/werkzeug/serving.py:1062, in run_simple(hostname, port, application, use_reloader, use_debugger, use_evalex, extra_files, exclude_patterns, reloader_interval, reloader_type, threaded, processes, request_handler, static_files, passthrough_errors, ssl_context)
1061 if not is_running_from_reloader():
-> 1062 s = prepare_socket(hostname, port)
1063 fd = s.fileno()
File ~/miniconda3/lib/python3.9/site-packages/werkzeug/serving.py:930, in prepare_socket(hostname, port)
924 print(
925 "On macOS, try disabling the 'AirPlay Receiver'"
926 " service from System Preferences -> Sharing.",
927 file=sys.stderr,
928 )
--> 930 sys.exit(1)
932 s.listen(LISTEN_QUEUE)
SystemExit: 1
During handling of the above exception, another exception occurred:
AssertionError Traceback (most recent call last)
[... skipping hidden 1 frame]
File ~/miniconda3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:1987, in InteractiveShell.showtraceback(self, exc_tuple, filename, tb_offset, exception_only, running_compiled_code)
1984 if exception_only:
1985 stb = ['An exception has occurred, use %tb to see '
1986 'the full traceback.\n']
-> 1987 stb.extend(self.InteractiveTB.get_exception_only(etype,
1988 value))
1989 else:
1990 try:
1991 # Exception classes can customise their traceback - we
1992 # use this in IPython.parallel for exceptions occurring
1993 # in the engines. This should return a list of strings.
File ~/miniconda3/lib/python3.9/site-packages/IPython/core/ultratb.py:579, in ListTB.get_exception_only(self, etype, value)
571 def get_exception_only(self, etype, value):
572 """Only print the exception type and message, without a traceback.
573
574 Parameters
(...)
577 value : exception value
578 """
--> 579 return ListTB.structured_traceback(self, etype, value)
File ~/miniconda3/lib/python3.9/site-packages/IPython/core/ultratb.py:446, in ListTB.structured_traceback(self, etype, evalue, etb, tb_offset, context)
443 chained_exc_ids.add(id(exception[1]))
444 chained_exceptions_tb_offset = 0
445 out_list = (
--> 446 self.structured_traceback(
447 etype, evalue, (etb, chained_exc_ids),
448 chained_exceptions_tb_offset, context)
449 + chained_exception_message
450 + out_list)
452 return out_list
File ~/miniconda3/lib/python3.9/site-packages/IPython/core/ultratb.py:1112, in AutoFormattedTB.structured_traceback(self, etype, value, tb, tb_offset, number_of_lines_of_context)
1110 else:
1111 self.tb = tb
-> 1112 return FormattedTB.structured_traceback(
1113 self, etype, value, tb, tb_offset, number_of_lines_of_context)
File ~/miniconda3/lib/python3.9/site-packages/IPython/core/ultratb.py:1006, in FormattedTB.structured_traceback(self, etype, value, tb, tb_offset, number_of_lines_of_context)
1003 mode = self.mode
1004 if mode in self.verbose_modes:
1005 # Verbose modes need a full traceback
-> 1006 return VerboseTB.structured_traceback(
1007 self, etype, value, tb, tb_offset, number_of_lines_of_context
1008 )
1009 elif mode == 'Minimal':
1010 return ListTB.get_exception_only(self, etype, value)
File ~/miniconda3/lib/python3.9/site-packages/IPython/core/ultratb.py:859, in VerboseTB.structured_traceback(self, etype, evalue, etb, tb_offset, number_of_lines_of_context)
850 def structured_traceback(
851 self,
852 etype: type,
(...)
856 number_of_lines_of_context: int = 5,
857 ):
858 """Return a nice text document describing the traceback."""
--> 859 formatted_exception = self.format_exception_as_a_whole(etype, evalue, etb, number_of_lines_of_context,
860 tb_offset)
862 colors = self.Colors # just a shorthand + quicker name lookup
863 colorsnormal = colors.Normal # used a lot
File ~/miniconda3/lib/python3.9/site-packages/IPython/core/ultratb.py:793, in VerboseTB.format_exception_as_a_whole(self, etype, evalue, etb, number_of_lines_of_context, tb_offset)
790 assert isinstance(tb_offset, int)
791 head = self.prepare_header(etype, self.long_header)
792 records = (
--> 793 self.get_records(etb, number_of_lines_of_context, tb_offset) if etb else []
794 )
796 frames = []
797 skipped = 0
File ~/miniconda3/lib/python3.9/site-packages/IPython/core/ultratb.py:848, in VerboseTB.get_records(self, etb, number_of_lines_of_context, tb_offset)
842 formatter = None
843 options = stack_data.Options(
844 before=before,
845 after=after,
846 pygments_formatter=formatter,
847 )
--> 848 return list(stack_data.FrameInfo.stack_data(etb, options=options))[tb_offset:]
File ~/miniconda3/lib/python3.9/site-packages/stack_data/core.py:578, in FrameInfo.stack_data(cls, frame_or_tb, options, collapse_repeated_frames)
562 @classmethod
563 def stack_data(
564 cls,
(...)
568 collapse_repeated_frames: bool = True
569 ) -> Iterator[Union['FrameInfo', RepeatedFrames]]:
570 """
571 An iterator of FrameInfo and RepeatedFrames objects representing
572 a full traceback or stack. Similar consecutive frames are collapsed into RepeatedFrames
(...)
576 and optionally an Options object to configure.
577 """
--> 578 stack = list(iter_stack(frame_or_tb))
580 # Reverse the stack from a frame so that it's in the same order
581 # as the order from a traceback, which is the order of a printed
582 # traceback when read top to bottom (most recent call last)
583 if is_frame(frame_or_tb):
File ~/miniconda3/lib/python3.9/site-packages/stack_data/utils.py:98, in iter_stack(frame_or_tb)
96 while frame_or_tb:
97 yield frame_or_tb
---> 98 if is_frame(frame_or_tb):
99 frame_or_tb = frame_or_tb.f_back
100 else:
File ~/miniconda3/lib/python3.9/site-packages/stack_data/utils.py:91, in is_frame(frame_or_tb)
90 def is_frame(frame_or_tb: Union[FrameType, TracebackType]) -> bool:
---> 91 assert_(isinstance(frame_or_tb, (types.FrameType, types.TracebackType)))
92 return isinstance(frame_or_tb, (types.FrameType,))
File ~/miniconda3/lib/python3.9/site-packages/stack_data/utils.py:172, in assert_(condition, error)
170 if isinstance(error, str):
171 error = AssertionError(error)
--> 172 raise error
AssertionError:
EDIT:
I add debug=True and this is my output:
Dash is running on http://localhost.localdomain:4050/
Dash is running on http://localhost.localdomain:4050/
Dash is running on http://localhost.localdomain:4050/
Dash is running on http://localhost.localdomain:4050/
Dash is running on http://localhost.localdomain:4050/
Dash is running on http://localhost.localdomain:4050/
* Serving Flask app '__main__'
* Debug mode: on
Name or service not known
---------------------------------------------------------------------------
gaierror Traceback (most recent call last)
File ~/miniconda3/lib/python3.9/site-packages/werkzeug/serving.py:911, in prepare_socket(hostname, port)
910 try:
--> 911 s.bind(server_address)
912 except OSError as e:
gaierror: [Errno -2] Name or service not known
During handling of the above exception, another exception occurred:
SystemExit Traceback (most recent call last)
[... skipping hidden 1 frame]
Cell In [11], line 8
7 if __name__=='__main__':
----> 8 app.run_server(port=4050, debug=True)
File ~/miniconda3/lib/python3.9/site-packages/dash/dash.py:2128, in Dash.run_server(self, *args, **kwargs)
2123 """`run_server` is a deprecated alias of `run` and may be removed in a
2124 future version. We recommend using `app.run` instead.
2125
2126 See `app.run` for usage information.
2127 """
-> 2128 self.run(*args, **kwargs)
File ~/miniconda3/lib/python3.9/site-packages/dash/dash.py:1961, in Dash.run(self, host, port, proxy, debug, dev_tools_ui, dev_tools_props_check, dev_tools_serve_dev_bundles, dev_tools_hot_reload, dev_tools_hot_reload_interval, dev_tools_hot_reload_watch_interval, dev_tools_hot_reload_max_retry, dev_tools_silence_routes_logging, dev_tools_prune_errors, **flask_run_options)
1959 extra_files.append(path)
-> 1961 self.server.run(host=host, port=port, debug=debug, **flask_run_options)
File ~/miniconda3/lib/python3.9/site-packages/flask/app.py:1188, in Flask.run(self, host, port, debug, load_dotenv, **options)
1187 try:
-> 1188 run_simple(t.cast(str, host), port, self, **options)
1189 finally:
1190 # reset the first request information if the development server
1191 # reset normally. This makes it possible to restart the server
1192 # without reloader and that stuff from an interactive shell.
File ~/miniconda3/lib/python3.9/site-packages/werkzeug/serving.py:1062, in run_simple(hostname, port, application, use_reloader, use_debugger, use_evalex, extra_files, exclude_patterns, reloader_interval, reloader_type, threaded, processes, request_handler, static_files, passthrough_errors, ssl_context)
1061 if not is_running_from_reloader():
-> 1062 s = prepare_socket(hostname, port)
1063 fd = s.fileno()
File ~/miniconda3/lib/python3.9/site-packages/werkzeug/serving.py:930, in prepare_socket(hostname, port)
924 print(
925 "On macOS, try disabling the 'AirPlay Receiver'"
926 " service from System Preferences -> Sharing.",
927 file=sys.stderr,
928 )
--> 930 sys.exit(1)
932 s.listen(LISTEN_QUEUE)
SystemExit: 1
During handling of the above exception, another exception occurred:
AssertionError Traceback (most recent call last)
[... skipping hidden 1 frame]
File ~/miniconda3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:1987, in InteractiveShell.showtraceback(self, exc_tuple, filename, tb_offset, exception_only, running_compiled_code)
1984 if exception_only:
1985 stb = ['An exception has occurred, use %tb to see '
1986 'the full traceback.\n']
-> 1987 stb.extend(self.InteractiveTB.get_exception_only(etype,
1988 value))
1989 else:
1990 try:
1991 # Exception classes can customise their traceback - we
1992 # use this in IPython.parallel for exceptions occurring
1993 # in the engines. This should return a list of strings.
File ~/miniconda3/lib/python3.9/site-packages/IPython/core/ultratb.py:579, in ListTB.get_exception_only(self, etype, value)
571 def get_exception_only(self, etype, value):
572 """Only print the exception type and message, without a traceback.
573
574 Parameters
(...)
577 value : exception value
578 """
--> 579 return ListTB.structured_traceback(self, etype, value)
File ~/miniconda3/lib/python3.9/site-packages/IPython/core/ultratb.py:446, in ListTB.structured_traceback(self, etype, evalue, etb, tb_offset, context)
443 chained_exc_ids.add(id(exception[1]))
444 chained_exceptions_tb_offset = 0
445 out_list = (
--> 446 self.structured_traceback(
447 etype, evalue, (etb, chained_exc_ids),
448 chained_exceptions_tb_offset, context)
449 + chained_exception_message
450 + out_list)
452 return out_list
File ~/miniconda3/lib/python3.9/site-packages/IPython/core/ultratb.py:1112, in AutoFormattedTB.structured_traceback(self, etype, value, tb, tb_offset, number_of_lines_of_context)
1110 else:
1111 self.tb = tb
-> 1112 return FormattedTB.structured_traceback(
1113 self, etype, value, tb, tb_offset, number_of_lines_of_context)
File ~/miniconda3/lib/python3.9/site-packages/IPython/core/ultratb.py:1006, in FormattedTB.structured_traceback(self, etype, value, tb, tb_offset, number_of_lines_of_context)
1003 mode = self.mode
1004 if mode in self.verbose_modes:
1005 # Verbose modes need a full traceback
-> 1006 return VerboseTB.structured_traceback(
1007 self, etype, value, tb, tb_offset, number_of_lines_of_context
1008 )
1009 elif mode == 'Minimal':
1010 return ListTB.get_exception_only(self, etype, value)
File ~/miniconda3/lib/python3.9/site-packages/IPython/core/ultratb.py:859, in VerboseTB.structured_traceback(self, etype, evalue, etb, tb_offset, number_of_lines_of_context)
850 def structured_traceback(
851 self,
852 etype: type,
(...)
856 number_of_lines_of_context: int = 5,
857 ):
858 """Return a nice text document describing the traceback."""
--> 859 formatted_exception = self.format_exception_as_a_whole(etype, evalue, etb, number_of_lines_of_context,
860 tb_offset)
862 colors = self.Colors # just a shorthand + quicker name lookup
863 colorsnormal = colors.Normal # used a lot
File ~/miniconda3/lib/python3.9/site-packages/IPython/core/ultratb.py:793, in VerboseTB.format_exception_as_a_whole(self, etype, evalue, etb, number_of_lines_of_context, tb_offset)
790 assert isinstance(tb_offset, int)
791 head = self.prepare_header(etype, self.long_header)
792 records = (
--> 793 self.get_records(etb, number_of_lines_of_context, tb_offset) if etb else []
794 )
796 frames = []
797 skipped = 0
File ~/miniconda3/lib/python3.9/site-packages/IPython/core/ultratb.py:848, in VerboseTB.get_records(self, etb, number_of_lines_of_context, tb_offset)
842 formatter = None
843 options = stack_data.Options(
844 before=before,
845 after=after,
846 pygments_formatter=formatter,
847 )
--> 848 return list(stack_data.FrameInfo.stack_data(etb, options=options))[tb_offset:]
File ~/miniconda3/lib/python3.9/site-packages/stack_data/core.py:578, in FrameInfo.stack_data(cls, frame_or_tb, options, collapse_repeated_frames)
562 @classmethod
563 def stack_data(
564 cls,
(...)
568 collapse_repeated_frames: bool = True
569 ) -> Iterator[Union['FrameInfo', RepeatedFrames]]:
570 """
571 An iterator of FrameInfo and RepeatedFrames objects representing
572 a full traceback or stack. Similar consecutive frames are collapsed into RepeatedFrames
(...)
576 and optionally an Options object to configure.
577 """
--> 578 stack = list(iter_stack(frame_or_tb))
580 # Reverse the stack from a frame so that it's in the same order
581 # as the order from a traceback, which is the order of a printed
582 # traceback when read top to bottom (most recent call last)
583 if is_frame(frame_or_tb):
File ~/miniconda3/lib/python3.9/site-packages/stack_data/utils.py:98, in iter_stack(frame_or_tb)
96 while frame_or_tb:
97 yield frame_or_tb
---> 98 if is_frame(frame_or_tb):
99 frame_or_tb = frame_or_tb.f_back
100 else:
File ~/miniconda3/lib/python3.9/site-packages/stack_data/utils.py:91, in is_frame(frame_or_tb)
90 def is_frame(frame_or_tb: Union[FrameType, TracebackType]) -> bool:
---> 91 assert_(isinstance(frame_or_tb, (types.FrameType, types.TracebackType)))
92 return isinstance(frame_or_tb, (types.FrameType,))
File ~/miniconda3/lib/python3.9/site-packages/stack_data/utils.py:172, in assert_(condition, error)
170 if isinstance(error, str):
171 error = AssertionError(error)
--> 172 raise error
AssertionError: