运行Dash应用程序时名称或服务未知

时间:2020-04-03 06:31:42

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

我的设置非常简单,但是无法运行。我怀疑这与服务器地址有关(我认为应该是https://127.0.0.1:8050),但不知道如何更改它。任何建议高度赞赏。 -设置虚拟环境并安装dash(使用pip install dash)。它还安装了flask

我对应用程序的基本设置:

import dash
import dash_html_components as html

app = dash.Dash()

app.layout = html.Div(
    html.H1(children="Hello World!")
)

if __name__ == '__main__':
    app.run_server(debug=True)

在终端中运行我的应用程序时,出现以下错误:

(Dash) rene@ideapad:~/Projects/Dash$ python my_app.py 
Running on http://x86_64-conda_cos6-linux-gnu:8050/
Debugger PIN: 287-942-334
 * Serving Flask app "my_app" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: on
Traceback (most recent call last):
  File "my_app.py", line 12, in <module>
    app.run_server(debug=True)
  File "/home/rene/Environments/Dash/lib/python3.7/site-packages/dash/dash.py", line 1973, in run_server
    self.server.run(host=host, port=port, debug=debug, **flask_run_options)
  File "/home/rene/Environments/Dash/lib/python3.7/site-packages/flask/app.py", line 990, in run
    run_simple(host, port, self, **options)
  File "/home/rene/Environments/Dash/lib/python3.7/site-packages/werkzeug/serving.py", line 1030, in run_simple
    s.bind(server_address)
socket.gaierror: [Errno -2] Name or service not known

1 个答案:

答案 0 :(得分:4)

我通过手动设置主机和端口来解决此问题:

if __name__ == '__main__':
    app.run_server(host='127.0.0.1', port='8050', debug=True)

但是我仍然不知道为什么它开始使用http://x86_64-conda_cos6-linux-gnu:8050

有什么建议吗?