2

I am new to dash and having an issue I can't find an answer for. I can run dash app successfully on jupyter notebook but it's not working when I run it via the terminal despite not giving an error. It just doesn't load my locahost. Below is my code

import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.express as px
import pandas as pd

external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)

# assume you have a "long-form" data frame
# see https://plotly.com/python/px-arguments/ for more options
df = pd.DataFrame({
    "Fruit": ["Apples", "Oranges", "Bananas", "Apples", "Oranges", "Bananas"],
    "Amount": [4, 1, 2, 2, 4, 5],
    "City": ["SF", "SF", "SF", "Montreal", "Montreal", "Montreal"]
})

fig = px.bar(df, x="Fruit", y="Amount", color="City", barmode="group")

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=fig
    )
])

if __name__ == '__main__':
    app.run_server(debug=False)

image of my terminal

image of directory structure

Kindly assist. What am I doing wrong?

EAyeni
  • 23
  • 5
  • Can you also share the structure of your directories and indicate which file is this Dash app? – coralvanda Sep 07 '20 at 00:55
  • try to run it in normal console/terminal/cmd.exe, not in terminal in IDE. Maybe problem is only IDE. – furas Sep 07 '20 at 03:38
  • When I run your code in console/shell in Linux then it shows me `Dash is running on http://127.0.0.1:8050/` and I can open it in web browser to see graph – furas Sep 07 '20 at 03:40
  • @Furas, I have tried this multiple times but it still doesn't work. – EAyeni Sep 07 '20 at 19:09
  • did you try it in real terminal/console/cmd.exe/ps.exe - not inside IDE ? – furas Sep 07 '20 at 19:19
  • @Furah, yes I did. Not response still. I have added a picture of my directory structure. "Visuals.py" is my file – EAyeni Sep 07 '20 at 19:41
  • I finally figured it out! My python executable path for my IDE was wrong all along..OR I didn't pay attention to it hence I was using the wrong command to run the app – EAyeni Sep 08 '20 at 00:12

0 Answers0