Dash服务器即使在更改端口后也未运行

2024-09-30 12:12:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在学习python Dash,因此使用了Dash网站中给出的相同代码-https://dash.plot.ly/getting-started,但是当我在空闲状态下运行时,它会给我一个错误,如下所示。我使用了网站中给出的正常服务器,然后更改了端口,仍然没有任何效果

# -*- coding: utf-8 -*-
import dash
import dash_core_components as dcc
import dash_html_components as html

external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)

app.layout = html.Div(children=[
    html.H1(children='Hello Dash'),

    html.Div(children='''
        Dash: A web application framework for Python.
    '''),

    dcc.Graph(
        id='example-graph',
        figure={
            'data': [
                {'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name': 'SF'},
                {'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name': u'Montréal'},
            ],
            'layout': {
                'title': 'Dash Data Visualization'
            }
        }
    )
])

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

这里是错误

Running on http://127.0.0.1:5500/
Debugger PIN: 419-348-850
Traceback (most recent call last):
  File "C:\Users\shaum\Documents\Python_Dash\testa.py", line 32, in <module>
    app.run_server(debug=True, port=5500)
  File "C:\Users\shaum\AppData\Local\Programs\Python\Python38-32\lib\site-packages\dash\dash.py", line 2026, in run_server
    self.server.run(port=port, debug=debug, **flask_run_options)
  File "C:\Users\shaum\AppData\Local\Programs\Python\Python38-32\lib\site-packages\flask\app.py", line 985, in run
    cli.show_server_banner(self.env, self.debug, self.name, False)
  File "C:\Users\shaum\AppData\Local\Programs\Python\Python38-32\lib\site-packages\flask\cli.py", line 670, in show_server_banner
    click.echo(message)
  File "C:\Users\shaum\AppData\Local\Programs\Python\Python38-32\lib\site-packages\click\utils.py", line 218, in echo
    file = _default_text_stdout()
  File "C:\Users\shaum\AppData\Local\Programs\Python\Python38-32\lib\site-packages\click\_compat.py", line 675, in func
    rv = wrapper_func()
  File "C:\Users\shaum\AppData\Local\Programs\Python\Python38-32\lib\site-packages\click\_compat.py", line 436, in get_text_stdout
    rv = _get_windows_console_stream(sys.stdout, encoding, errors)
  File "C:\Users\shaum\AppData\Local\Programs\Python\Python38-32\lib\site-packages\click\_winconsole.py", line 295, in _get_windows_console_stream
    func = _stream_factories.get(f.fileno())
io.UnsupportedOperation: fileno

Tags: inpylibpackageslocallinesiteusers

热门问题