plotly dash 图表:无法访问站点
plotly dash chart: site can't be reached
我正在尝试 运行 Google Colab 上的 plotly 应用程序:
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import plotly.express as px
import socket
host = socket.gethostbyname(socket.gethostname())
themes = (
raw.themes_simple.drop_duplicates()
.sample(n=10, random_state=42)
)
app = dash.Dash(__name__)
app.layout = html.Div([
html.P("Select y-axis"),
dcc.Dropdown(
id='y-axis',
options=[
{'label': x, 'value': x}
for x in ['themes_simple']],
value='pop'
),
dcc.Graph(id="graph"),
])
@app.callback(
Output("graph", "figure"),
[Input("y-axis", "value")])
def display_area(y):
fig = px.area(
raw, x=raw.columns.to_list()[1:], y=y,
color="themes_simple", line_group="countries")
return fig
app.run_server(debug=False, host=host, port = 5000)
我收到消息了
Dash 在 http://IP_address:5000/
上 运行ning
- Serving Flask 应用“main”(延迟加载)
- 环境:生产
警告:这是一个开发服务器。不要在生产部署中使用它。
请改用生产 WSGI 服务器。
- 调试模式:关闭
- 运行 在 http://IP_address:5000/(按 CTRL+C 退出)
但是,当我单击 link 时,我收到消息“无法显示页面”。
知道我还能尝试什么吗?
问题是 link,dash 应用程序没问题,您需要获得一个 link 才能访问。显示的 link 是您无权访问的服务器的本地主机。但是你可以有服务器的代理:
from google.colab.output import eval_js
print(eval_js("google.colab.kernel.proxyPort(5000)"))
先执行这两行,然后再执行您的应用程序。访问打印出来的 link,您应该能够看到您的应用程序。
我正在尝试 运行 Google Colab 上的 plotly 应用程序:
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import plotly.express as px
import socket
host = socket.gethostbyname(socket.gethostname())
themes = (
raw.themes_simple.drop_duplicates()
.sample(n=10, random_state=42)
)
app = dash.Dash(__name__)
app.layout = html.Div([
html.P("Select y-axis"),
dcc.Dropdown(
id='y-axis',
options=[
{'label': x, 'value': x}
for x in ['themes_simple']],
value='pop'
),
dcc.Graph(id="graph"),
])
@app.callback(
Output("graph", "figure"),
[Input("y-axis", "value")])
def display_area(y):
fig = px.area(
raw, x=raw.columns.to_list()[1:], y=y,
color="themes_simple", line_group="countries")
return fig
app.run_server(debug=False, host=host, port = 5000)
我收到消息了 Dash 在 http://IP_address:5000/
上 运行ning- Serving Flask 应用“main”(延迟加载)
- 环境:生产 警告:这是一个开发服务器。不要在生产部署中使用它。 请改用生产 WSGI 服务器。
- 调试模式:关闭
- 运行 在 http://IP_address:5000/(按 CTRL+C 退出)
但是,当我单击 link 时,我收到消息“无法显示页面”。
知道我还能尝试什么吗?
问题是 link,dash 应用程序没问题,您需要获得一个 link 才能访问。显示的 link 是您无权访问的服务器的本地主机。但是你可以有服务器的代理:
from google.colab.output import eval_js
print(eval_js("google.colab.kernel.proxyPort(5000)"))
先执行这两行,然后再执行您的应用程序。访问打印出来的 link,您应该能够看到您的应用程序。