Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 从Jupyter笔记本启动Dash_Python_Jupyter Notebook_Plotly_Plotly Dash - Fatal编程技术网

Python 从Jupyter笔记本启动Dash

Python 从Jupyter笔记本启动Dash,python,jupyter-notebook,plotly,plotly-dash,Python,Jupyter Notebook,Plotly,Plotly Dash,有没有办法使用Jupyter笔记本下面的代码行启动仪表板 # if __name__ == '__main__': # app.run_server(debug=True) 当我试着启动它时,我得到了一个错误 唯一的纠正方法是将debug设置为false。但是,当输入图表的数据被更改时,仪表板不会自动更新。编辑 我刚刚发现一位有价值的GitHub用户发布了这个。这是到相应的服务器的直接链接。请参阅他的文档和示例,以便在jupyter中成功实现它。这对我有用 在安装库之前不要低估这句话:

有没有办法使用Jupyter笔记本下面的代码行启动仪表板

# if __name__ == '__main__':
#     app.run_server(debug=True)
当我试着启动它时,我得到了一个错误

唯一的纠正方法是将debug设置为false。但是,当输入图表的数据被更改时,仪表板不会自动更新。

编辑

我刚刚发现一位有价值的GitHub用户发布了这个。这是到相应的服务器的直接链接。请参阅他的文档和示例,以便在jupyter中成功实现它。这对我有用

在安装库之前不要低估这句话:“强烈建议使用VirtualEnvironment”

原创帖子

不久前我自己也有这个问题。我不知道现在它是否是本地修复的。当时我用的变通方法就是这个。它直接来自Chris本人,但仍然有
debug=False

from IPython import display
def show_app(app,  # type: dash.Dash
             port=9999,
             width=700,
             height=350,
             offline=True,
             style=True,
             **dash_flask_kwargs):
    """
    Run the application inside a Jupyter notebook and show an iframe with it
    :param app:
    :param port:
    :param width:
    :param height:
    :param offline:
    :return:
    """
    url = 'http://localhost:%d' % port
    iframe = '<iframe src="{url}" width={width} height={height}></iframe>'.format(url=url,
                                                                                  width=width,
                                                                                  height=height)
    display.display_html(iframe, raw=True)
    if offline:
        app.css.config.serve_locally = True
        app.scripts.config.serve_locally = True
    if style:
        external_css = ["https://fonts.googleapis.com/css?family=Raleway:400,300,600",
                        "https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css",
                        "http://getbootstrap.com/dist/css/bootstrap.min.css", ]

        for css in external_css:
            app.css.append_css({"external_url": css})

        external_js = ["https://code.jquery.com/jquery-3.2.1.min.js",
                       "https://cdn.rawgit.com/plotly/dash-app-stylesheets/a3401de132a6d0b652ba11548736b1d1e80aa10d/dash-goldman-sachs-report-js.js",
                       "http://getbootstrap.com/dist/js/bootstrap.min.js"]

        for js in external_js:
            app.scripts.append_script({"external_url": js})

    return app.run_server(debug=False,  # needs to be false in Jupyter
                          port=port,
                          **dash_flask_kwargs)
从IPython导入显示
def显示应用程序(应用程序,#类型:破折号。破折号
端口=9999,
宽度=700,
高度=350,
离线=真,
风格=正确,
**破折号(烧瓶):
"""
在Jupyter笔记本中运行应用程序,并显示一个iframe
:param应用程序:
:参数端口:
:参数宽度:
:参数高度:
:param offline:
:返回:
"""
url='1〕http://localhost:%d%端口
iframe=''.format(url=url,
宽度=宽度,
高度=高度)
display.display_html(iframe,raw=True)
如果脱机:
app.css.config.service_locally=True
app.scripts.config.service_locally=True
如果样式:
外部_css=[”https://fonts.googleapis.com/css?family=Raleway:400,300,600",
"https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css",
"http://getbootstrap.com/dist/css/bootstrap.min.css", ]
对于外部_css中的css:
append_css({“external_url”:css})
外部_js=[”https://code.jquery.com/jquery-3.2.1.min.js",
"https://cdn.rawgit.com/plotly/dash-app-stylesheets/a3401de132a6d0b652ba11548736b1d1e80aa10d/dash-goldman-sachs-report-js.js",
"http://getbootstrap.com/dist/js/bootstrap.min.js"]
对于外部_js中的js:
append_脚本({“external_url”:js})
返回app.run_server(debug=False,#在Jupyter中必须为False
端口=端口,
**破折号(烧瓶)

那么像这样使用它就是为您切换回调函数?请展示你的程序的一些逻辑。也许我可以提供更多的建议。干杯。

我的回答解决了你的问题吗?如果有,请接受并投票:干杯,我不确定。在这一点上我很困惑。但我肯定是的,我只是慢了一点。没问题,如果你提出进一步的问题,我会支持你的