15

遵循情节破折号入门指南,但尝试运行python app.py获取消息时:

OSError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions

似乎默认地址:http://127.0.0.1:8050/已被使用。如何更改默认端口以使其正常工作?

4

5 回答 5

29

正如我们在 Dash.run_server 方法定义中看到的,端口可以作为参数传递:

def run_server(self,
               port=8050,
               debug=True,
               threaded=True,
               **flask_run_options):
    self.server.run(port=port, debug=debug, **flask_run_options)

因此,如果您需要使用另一个端口:

if __name__ == '__main__':
    app.run_server(debug=True, port=8051) # or whatever you choose
于 2017-08-23T08:46:25.060 回答
0

我在 Jupyter 笔记本上运行它,我所要做的就是进入运行时并选择恢复出厂设置运行时,pip 安装所有依赖项(如 jupyter-dash),我很高兴......

于 2021-07-03T05:24:09.107 回答
0

在 port = 8050 的地方输入您自己的端口号

于 2021-04-27T01:32:02.380 回答
0

请注意,在 Julia 中,您可以通过在run_server参数中指定端口号而不指定“port=”来更改端口。例如,

run_server(app, "0.0.0.0", 8000, debug = true)
于 2021-03-10T17:43:24.843 回答
0

您还可以在启动 Dash 应用程序之前在终端中设置环境变量 PORT:

https://github.com/plotly/dash/blob/c77912a3183adfccfd4ef84df91eca7fa9c7d543/dash/_configs.py#L34

于 2021-10-06T20:42:01.680 回答