Not able to start with Dash

Hello, I am trying to use Dash through anaconda. Trying the first tutorial code:
import dash

import dash_core_components as dcc
import dash_html_components as html

app=dash.Dash
dash.Dash.layout = html.Div(‘Dash’)

dash.Dash.layout = html.Div(children=[
html.H1(children=‘Hello Dash’),

html.Div(children='''
    Dash: A web application framework for Python.
'''),

dcc.Graph(
    id='example-graph',
    figure={
        'data': [
            {'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name': 'SF'},
            {'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name': u'Montréal'},
        ],
        'layout': {
            'title': 'Dash Data Visualization'
        }
    }
)

])

dash.Dash.css.config.serve_locally = True
dash.Dash.scripts.config.serve_locally = True
dash.Dash.css
if name == ‘main’:
dash.Dash.run_server(debug=True)

and running into
AttributeError: type object ‘Dash’ has no attribute ‘css’
if I remove dash.Dash.css.config.serve_locally - True, I run into
AttributeError: type object ‘Dash’ has no attribute ‘scripts’

Can someone please help me with this

Hi,

which tutorial are your referring about? There is several strange things in your code.

  • you define app as a the object dash.Dash, but:
    • you want app to be an instance of the class dash.Dash, so parenthesis are missing.
    • you never reuse app in your code… You need to remove all the dash.Dash by your instance app.
  • The dash.Dash.layout = html.Div("Dash") is useless as it will be erased by the next ‘dash.Dash.layout’ 2 lines after.

Here is a suggestion to make it works. (PS: frame it with ```py```) makes it nice to look at :slight_smile: )

import dash
import dash_core_components as dcc
import dash_html_components as html

app=dash.Dash()

app.layout = html.Div(children=[
    html.H1(children='Hello Dash'),
    html.Div(children='''
        Dash: A web application framework for Python.
    '''),

    dcc.Graph(
        id='example-graph',
        figure={
            'data': [
                {'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name': 'SF'},
                {'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name': u'Montréal'},
            ],
            'layout': {
                'title': 'Dash Data Visualization'
            }
        }
    )
])

app.css.config.serve_locally = True
app.scripts.config.serve_locally = True
#dash.Dash.css <- what's that ?
if __name__ == '__main__':
    app.run_server(debug=True)
2 Likes

Hi GwendalD, Thank you very much. This is the tutorial I was trying: https://dash.plot.ly/getting-started

I did try it with app yesterday and it didn’t work but somehow when I copied your code here, it’s doing fine. But now I am getting ‘* Restarting with stat’ and then that’s it. Doesn’t show or do anything. Did I miss any installation?

Hi, you’re welcome :slight_smile:

Ok, so you miss copy the tutorial. Furthermore, you mixed different tutorial (there is no css related stuff in this tuto).

So, if you do not see anything else in the terminal, it means that everything is fine, and you can go to http://localhost:8050/ and see your app.
This is what your terminal should say:

>>> python3 test.py
 * Running on http://127.0.0.1:8050/ (Press CTRL+C to quit)
 * Restarting with stat
2 Likes

dash.Dash-Not really. That was me misunderstanding a post to try to troubleshoot the given error
‘app.css.config.serve_locally = True’ - This is to try and run it locally in my pc. Is there a way to run this offline and save it in my PC?

hello guys am also trying to get started with dash , have created the file and the code is okay but when i try to run it am getting this error
Traceback (most recent call last):
File “C:\Users\MASELA\Desktop\dash\app.py”, line 31, in
app.run_server(debug=True)
File “C:\Python27\lib\site-packages\dash\dash.py”, line 1058, in run_server
**flask_run_options)
File “C:\Python27\lib\site-packages\flask\app.py”, line 938, in run
cli.show_server_banner(self.env, self.debug, self.name, False)
File “C:\Python27\lib\site-packages\flask\cli.py”, line 629, in show_server_banner
click.echo(message)
File “C:\Python27\lib\site-packages\click\utils.py”, line 218, in echo
file = _default_text_stdout()
File “C:\Python27\lib\site-packages\click_compat.py”, line 675, in func
rv = wrapper_func()
File “C:\Python27\lib\site-packages\click_compat.py”, line 243, in get_text_stdout
rv = _get_windows_console_stream(sys.stdout, encoding, errors)
File “C:\Python27\lib\site-packages\click_winconsole.py”, line 295, in _get_windows_console_stream
func = _stream_factories.get(f.fileno())
UnsupportedOperation: fileno

Hi I am also trying to start with Dash using the same tutorial.

https://dash.plot.ly/getting-started

when running it generates:

Running on http://127.0.0.1:8050/
Debugger PIN: 145-125-455
Running on http://127.0.0.1:8050/
Debugger PIN: 335-555-445

but the it does not loading both in IE and Chrome, the browser keeps “waiting…”

Can anyone help?

Hi, I got this error message when I ran the file with your codes… whats wrong with me? :slight_smile:

That’s normal, not an error message.

Although I have seen people having issues winning from within IDEs before. So if it’s not working, perhaps try running from the command line rather than from Spyder

I ran it in Anaconda prompt and got this

and then even if I changed some details in app.py. Nothing will be changed in the output. Why?

Dash runs as a web app, so you now need to open up the address http://127.0.0.1:8050 in a browser running on the same machine.

I have the same issue. The browser cannot load the URL. It is just loading forever.

not working
Running on http://127.0.0.1:8050/
Running on http://127.0.0.1:8050/
Running on http://127.0.0.1:8050/
Running on http://127.0.0.1:8050/
Debugger PIN: 433-951-773
Debugger PIN: 433-951-773
Debugger PIN: 433-951-773
Debugger PIN: 433-951-773

  • Serving Flask app “main” (lazy loading)
  • Environment: production
    WARNING: This is a development server. Do not use it in a production deployment.
    Use a production WSGI server instead.
  • Debug mode: on
    An exception has occurred, use %tb to see the full traceback.

SystemExit: 1

try setting app.run_server(debug=False)

1 Like

Thats Work!! Thanks @chriddyp