Python Forum
Errors while running dash plotly code
Thread Rating:
  • 2 Vote(s) - 2.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Errors while running dash plotly code
#1
Hello , I'm getting the following error while m running the below code in python shell directly, Can anyone please solve the problem:

# -*- coding: utf-8 -*-
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'
}
}
)
])

if __name__ == "__main__":
app.run_server(debug=True)

Unexpected error:
/opt/python/2.7.10/linux50_32/bin/python: can't find '__main__' module in ''
----------------------------------------------------------------------------
Thanks in advance
Reply
#2
Use code tags see BBCODE
when posting code, use ctrl-shift-v to eliminate formatting and maintain indentation

please re-post
Reply
#3
Hello , I'm getting the error while m running the below code in python shell directly, Can anyone please solve the problem:

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'
            }
        }
    )
])

if __name__ == '__main__':
    app.run_server(debug=True)
----------------------------------------------------------------
Output:
* Running on http://127.0.0.1:8050/ (Press CTRL+C to quit)
* Restarting with stat
/bin/python3.4: can't find '__main__' module in ''
Reply
#4
Please post full (verbatim) errors
from the one line that you supply, it sounds like there is no __main__ function which it is trying to run
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  running the code and seeing the GUI chriswrcg 1 761 May-19-2023, 04:49 PM
Last Post: deanhystad
  Updating/running code when path changes hermannhaf 14 2,993 Aug-05-2022, 09:37 PM
Last Post: woooee
  [PyQt] source code is not running in REDHAT 7 linux platform shridhara 0 2,093 May-23-2018, 07:58 AM
Last Post: shridhara

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020