# My Dash plotly app not working

**URL:** <https://community.plotly.com/t/my-dash-plotly-app-not-working/71200>\
**Category:** Dash Python\
**Tags:** question\
**Created:** [December 29, 2022, 4:48pm UTC](https://community.plotly.com/t/my-dash-plotly-app-not-working/71200 "2022-12-29T16:48:38Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![moizbaloch1](https://avatars.discourse-cdn.com/v4/letter/m/8c91f0/32.png) [@moizbaloch1](https://community.plotly.com/u/moizbaloch1)\
**Post date:** [December 29, 2022, 4:48pm UTC](https://community.plotly.com/t/my-dash-plotly-app-not-working/71200/1 "2022-12-29T16:48:38Z")

</div>

Hi, I have scripted an web app with dash.plotly. But having issues with it. Can anyone help me with it? I need it to be submitted tonight as a project.

---

<div class="post-metadata">

**Author:** ![jinnyzor](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jinnyzor/32/21194_2.png) [@jinnyzor](https://community.plotly.com/u/jinnyzor)\
**Post date:** [December 29, 2022, 4:49pm UTC](https://community.plotly.com/t/my-dash-plotly-app-not-working/71200/2 "2022-12-29T16:49:44Z")

</div>

Hello @moizbaloch1,

Welcome to the community!

This request is very vague, could you please provide more info about where you are having the issue.

Also, can you provide a MRE:

> [@How to write a Minimal Reproducible Example (MRE)](https://community.plotly.com/t/how-to-write-a-minimal-reproducible-example-mre/61502):
>
> Adding a minimal reproducible example to your questions will help attract community members to answer your question. The goal of writing a MRE is to allow other members of the community to run the code on their computers and “reproduce” the error, so that they can best help you. Please make sure that your MRE includes data and that the code is correctly pre-formatted. To preformat, copy and paste the code in your post and then click on \</\> (Preformatted text), as shown on the image:

---

<div class="post-metadata">

**Author:** ![moizbaloch1](https://avatars.discourse-cdn.com/v4/letter/m/8c91f0/32.png) [@moizbaloch1](https://community.plotly.com/u/moizbaloch1)\
**Post date:** [December 29, 2022, 5:06pm UTC](https://community.plotly.com/t/my-dash-plotly-app-not-working/71200/3 "2022-12-29T17:06:48Z")

</div>

```auto
import dash
from dash import html, dcc

PopulationDistribution = dash.Dash( __name__ , use_pages=True)

PopulationDistribution.layout = html.Div(
    [
        # main app framework
        html.Div("WorldWide Population Distribution", style={'fontSize':50, 'textAlign':'center'}),
        html.Div([
            dcc.Link(page['name']+" | ", href=page['path'])
            for page in dash.page_registry.values()
        ]),
        html.Hr(),

        # content of each page
        dash.page_container
    ]
)

if __name__ == " __main__":
    PopulationDistribution.run(debug=True)`Preformatted text`

```

---

<div class="post-metadata">

**Author:** ![jinnyzor](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jinnyzor/32/21194_2.png) [@jinnyzor](https://community.plotly.com/u/jinnyzor)\
**Post date:** [December 29, 2022, 5:11pm UTC](https://community.plotly.com/t/my-dash-plotly-app-not-working/71200/4 "2022-12-29T17:11:18Z")

</div>

Thank you, @moizbaloch1.

Do you have a pages folder in that directory? If not, your app wont load because it cant parse through any files.

Also, here is a standard way to initialize:

```auto
import dash
from dash import html, dcc, Dash

app = Dash( __name__ , use_pages=True)

app.layout = html.Div(
    [
        # main app framework
        html.Div("WorldWide Population Distribution", style={'fontSize':50, 'textAlign':'center'}),
        html.Div([
            dcc.Link(page['name']+" | ", href=page['path'])
            for page in dash.page_registry.values()
        ]),
        html.Hr(),

        # content of each page
        dash.page_container
    ]
)

if __name__ == " __main__":
    app.run(debug=True, port=12345)

```

The main thing was that typically we call it app, that way its easier to reference and copy & paste code. 🙂

---

<div class="post-metadata">

**Author:** ![moizbaloch1](https://avatars.discourse-cdn.com/v4/letter/m/8c91f0/32.png) [@moizbaloch1](https://community.plotly.com/u/moizbaloch1)\
**Post date:** [December 29, 2022, 5:13pm UTC](https://community.plotly.com/t/my-dash-plotly-app-not-working/71200/5 "2022-12-29T17:13:58Z")

</div>

I have directory for pages and also data file

---

<div class="post-metadata">

**Author:** ![jinnyzor](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jinnyzor/32/21194_2.png) [@jinnyzor](https://community.plotly.com/u/jinnyzor)\
**Post date:** [December 29, 2022, 5:15pm UTC](https://community.plotly.com/t/my-dash-plotly-app-not-working/71200/6 "2022-12-29T17:15:40Z")

</div>

Hmm…

The application runs fine if I have a pages\_folder.

Are you having issues with a specific folder? Can you copy my code and use it? Does it work?

---

<div class="post-metadata">

**Author:** ![moizbaloch1](https://avatars.discourse-cdn.com/v4/letter/m/8c91f0/32.png) [@moizbaloch1](https://community.plotly.com/u/moizbaloch1)\
**Post date:** [December 29, 2022, 5:19pm UTC](https://community.plotly.com/t/my-dash-plotly-app-not-working/71200/7 "2022-12-29T17:19:45Z")

</div>

Appis loading but , when i move to another page. there is an error that page not found Error 404

---

<div class="post-metadata">

**Author:** ![jinnyzor](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jinnyzor/32/21194_2.png) [@jinnyzor](https://community.plotly.com/u/jinnyzor)\
**Post date:** [December 29, 2022, 5:25pm UTC](https://community.plotly.com/t/my-dash-plotly-app-not-working/71200/8 "2022-12-29T17:25:44Z")

</div>

Can you post your other pages.py?

Do you have `layout = ` in each?

---

<div class="post-metadata">

**Author:** ![moizbaloch1](https://avatars.discourse-cdn.com/v4/letter/m/8c91f0/32.png) [@moizbaloch1](https://community.plotly.com/u/moizbaloch1)\
**Post date:** [December 29, 2022, 5:29pm UTC](https://community.plotly.com/t/my-dash-plotly-app-not-working/71200/9 "2022-12-29T17:29:20Z")

</div>

```auto
import dash
from dash import dcc, html
import plotly.express as px
import pandas as pd 

dash.register_page( __name__ )

df = pd.read_csv(r'd:\New\Data.csv')

layout = html.Div(
    [
        dcc.Dropdown([x for x in df.year.unique()], id='cont-choice', style={'width':'50%'}),
        dcc.Graph(id='line-fig',
                  figure=px.bar(df, x='country', y='population'))
    ]
)

```

---

<div class="post-metadata">

**Author:** ![moizbaloch1](https://avatars.discourse-cdn.com/v4/letter/m/8c91f0/32.png) [@moizbaloch1](https://community.plotly.com/u/moizbaloch1)\
**Post date:** [December 29, 2022, 5:30pm UTC](https://community.plotly.com/t/my-dash-plotly-app-not-working/71200/10 "2022-12-29T17:30:14Z")

</div>

Another Page\> Blockquote

import dash  
from dash import dcc, html  
import plotly.express as px  
import pandas as pd

dash.register\_page( **name** )

df = pd.read\_csv(r’d:\New\Data.csv’)

layout = html.Div(  
[  
dcc.Dropdown([x for x in df.year.unique()], id=‘cont-choice’, style={‘width’:‘50%’}),  
dcc.Graph(id=‘line-fig’,  
figure=px.bar(df, x=‘country’, y=‘population’))  
]  
)

---

<div class="post-metadata">

**Author:** ![jinnyzor](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jinnyzor/32/21194_2.png) [@jinnyzor](https://community.plotly.com/u/jinnyzor)\
**Post date:** [December 29, 2022, 5:31pm UTC](https://community.plotly.com/t/my-dash-plotly-app-not-working/71200/11 "2022-12-29T17:31:54Z")

</div>

Are there any errors in the console or anything that could shed some light?

---

<div class="post-metadata">

**Author:** ![moizbaloch1](https://avatars.discourse-cdn.com/v4/letter/m/8c91f0/32.png) [@moizbaloch1](https://community.plotly.com/u/moizbaloch1)\
**Post date:** [December 29, 2022, 5:32pm UTC](https://community.plotly.com/t/my-dash-plotly-app-not-working/71200/12 "2022-12-29T17:32:35Z")

</div>

if its okay, Can I email it to you , the zip file.

---

<div class="post-metadata">

**Author:** ![jinnyzor](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jinnyzor/32/21194_2.png) [@jinnyzor](https://community.plotly.com/u/jinnyzor)\
**Post date:** [December 29, 2022, 5:57pm UTC](https://community.plotly.com/t/my-dash-plotly-app-not-working/71200/13 "2022-12-29T17:57:23Z")

</div>

Issue is naming of the files leads to an incompatible path.

However, you can declare the path when you register the page and then it will work. 🙂

```plaintext
from dash import dcc, html
import plotly.express as px
import pandas as pd

dash.register_page( __name__ , path='/pop_per_country_selected')

df = pd.read_csv(r'Data.csv')

layout = html.Div(
    [
        dcc.Dropdown([x for x in df.year.unique()], id='cont-choice', style={'width':'50%'}),
        dcc.Graph(id='line-fig',
                  figure=px.bar(df, x='country', y='population'))
    ]
)

```

 ![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/9/6/96aba9a8b12e0a9c524122888716d7f5d2f3493f.png)

---

<div class="post-metadata">

**Author:** ![moizbaloch1](https://avatars.discourse-cdn.com/v4/letter/m/8c91f0/32.png) [@moizbaloch1](https://community.plotly.com/u/moizbaloch1)\
**Post date:** [December 29, 2022, 6:28pm UTC](https://community.plotly.com/t/my-dash-plotly-app-not-working/71200/14 "2022-12-29T18:28:34Z")

</div>

Thank you, still not working for me though

---

<div class="post-metadata">

**Author:** ![jinnyzor](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jinnyzor/32/21194_2.png) [@jinnyzor](https://community.plotly.com/u/jinnyzor)\
**Post date:** [December 29, 2022, 6:37pm UTC](https://community.plotly.com/t/my-dash-plotly-app-not-working/71200/15 "2022-12-29T18:37:25Z")

</div>

You’ll need to do it on all your files.

Is your main page loading with the graphs?
