Plotly Dash在jupyter上工作,但不在终端上工作

时间:2020-09-06 23:54:13

标签: python flask plotly data-visualization plotly-dash

我是新手,遇到一个我找不到答案的问题。我可以在jupyter笔记本上成功运行破折号应用程序,但是尽管没有出现错误,但通过终端运行它时却无法正常工作。它只是不会加载我的locahost。下面是我的代码

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

请协助。我在做什么错了?

0 个答案:

没有答案