[英]Running dash from jupyter notebook
I am trying to run dash through jupyter notebook but the app is not launching. 我正在尝试通过jupyter笔记本运行破折号,但该应用程序未启动。 I get SystemExit: 1 error. 我得到SystemExit:1错误。 Kindly help. 请帮助。 I am not asking to run within notebook but just to launch the web app. 我不是要在笔记本中运行而是要启动Web应用程序。 if I use a app.py file, it runs but why I can not run through jupyter notebook? 如果我使用app.py文件,它将运行,但是为什么无法通过jupyter Notebook运行?
'''
import dash
import dash_cytoscape as cyto
import dash_html_components as html
app = dash.Dash(__name__)
app.layout = html.Div([
cyto.Cytoscape(
id='cytoscape',
elements=[
{'data': {'id': 'one', 'label': 'Node 1'}, 'position': {'x': 50, 'y': 50}},
{'data': {'id': 'two', 'label': 'Node 2'}, 'position': {'x': 200, 'y': 200}},
{'data': {'source': 'one', 'target': 'two','label': 'Node 1 to 2'}}
],
layout={'name': 'preset'}
)
])
if __name__ == '__main__':
app.run_server(debug=True,port=5001)
I get this error: 我收到此错误:
Running on http://127.0.0.1:5001/
Running on http://127.0.0.1:5001/
Debugger PIN: 699-998-824
Debugger PIN: 699-998-824
* Serving Flask app "__main__" (lazy loading)
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: on
An exception has occurred, use %tb to see the full traceback.
SystemExit: 1
/anaconda3/lib/python3.7/site-packages/IPython/core/interactiveshell.py:3275: UserWarning:
To exit: use 'exit', 'quit', or Ctrl-D.
%tb for this flask issue: 此烧瓶问题的%tb:
@idontcare You have to change few lines to run this code in jupyter notebook. @idontcare您必须更改几行才能在jupyter笔记本中运行此代码。 first install jupyter plotly dash with 首先安装jupyter plotly dash与
[pip install jupyter-plotly-dash] The Django in this installation needs to be set by installing [pip install -U django-plotly-dash==0.9.8]. [pip install jupyter-plotly-dash]需要通过安装[pip install -U django-plotly-dash == 0.9.8]来设置此安装中的Django。
Then the dash that comes with jupyter-plotly-dash installation have a bug and needs to be downgraded to 0.38.0. 然后,jupyter-plotly-dash安装随附的破折号有一个错误,需要降级至0.38.0。 you can install this with [pip install dash==0.38.0] 您可以使用[pip install dash == 0.38.0]进行安装
see updated code: 查看更新的代码:
''' '''
from jupyter_plotly_dash import JupyterDash
import dash
import dash_cytoscape as cyto
import dash_html_components as html
app = JupyterDash('YourAppExample')
app.layout = html.Div([
cyto.Cytoscape(
id='cytoscape',
elements=[
{'data': {'id': 'one', 'label': 'Node 1'}, 'position': {'x': 50, 'y': 50}},
{'data': {'id': 'two', 'label': 'Node 2'}, 'position': {'x': 200, 'y': 200}},
{'data': {'source': 'one', 'target': 'two','label': 'Node 1 to 2'}}
],
layout={'name': 'preset'}
)
])
app
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.