Unable to load dash from terminal or IDE

I am unable to load dash app from my terminal or IDE despite giving no errors. I used the same code in Jupyter notebook and it worked but never loads when I run it via terminal. Below is a screenshot and 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(host='127.0.0.1', port=8050, debug=False)

Please help

Hi @eayeni
Your problem is not with the code, it’s with the IDE environment. You don’t have Dash installed in there. To verify whether you have Dash installed, just

import dash
print(dash.__version__)

If you have it installed, you’ll get the version

I am not getting any output either. Please find below screenshot. The dash packages is in my python environments when I check it though…

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

You were right. I didn’t have it installed…in the right path. Thank you

1 Like