我正在尝试使用Dash框架开发应用程序,但是在运行代码时,出现“回溯”错误。
我正在通过IDLE学习它,但是我已经尝试用Jupyter编写代码。我得到了不同的错误,但是似乎没有一个起作用。
import dash
import dash_core_components as dcc
import dash_html_components as html
app = dash.Dash()
app.layout = html.Div(children=[
html.H1(children='Dash Tutorials'),
dcc.Graph()
])
if __name__ == '__main__':
app.run_server(debug=True)
这是我从IDLE获得的结果:
RESTART: C:/Users/Amanda/Google Drive/00.Studies/0.Python/6.Applications/1.Dash/1.Application with Dash.py
Running on http://127.0.0.1:8050/
Debugger PIN: 197-211-663
Traceback (most recent call last):
File "C:/Users/Amanda/Google Drive/00.Studies/0.Python/6.Applications/1.Dash/1.Application with Dash.py", line 13, in <module>
app.run_server(debug=True)
File "C:\Users\Amanda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\dash\dash.py", line 1492, in run_server
**flask_run_options)
File "C:\Users\Amanda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\flask\app.py", line 938, in run
cli.show_server_banner(self.env, self.debug, self.name, False)
File "C:\Users\Amanda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\flask\cli.py", line 629, in show_server_banner
click.echo(message)
File "C:\Users\Amanda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\click\utils.py", line 218, in echo
file = _default_text_stdout()
File "C:\Users\Amanda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\click\_compat.py", line 675, in func
rv = wrapper_func()
File "C:\Users\Amanda\AppData\Local\Programs\Python\Python37-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\Amanda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\click\_winconsole.py", line 295, in _get_windows_console_stream
func = _stream_factories.get(f.fileno())
io.UnsupportedOperation: fileno
这是我从Jupyter Notebook得到的结果:
OSError Traceback (most recent call last)
<ipython-input-2-efe85771a25b> in <module>
----> 1 import dash
2 import dash_core_components as dcc
3 import dash_html_components as html
4
5 app = dash.Dash()
~\Anaconda3\lib\site-packages\dash\__init__.py in <module>
----> 1 from .dash import Dash, no_update # noqa: F401
2 from . import dependencies # noqa: F401
3 from . import development # noqa: F401
4 from . import exceptions # noqa: F401
5 from . import resources # noqa: F401
~\Anaconda3\lib\site-packages\dash\dash.py in <module>
21 from flask_compress import Compress
22
---> 23 import plotly
24 import dash_renderer
25
~\Anaconda3\lib\site-packages\plotly\__init__.py in <module>
29 from __future__ import absolute_import
30
---> 31 from plotly import (plotly, dashboard_objs, graph_objs, grid_objs, tools,
32 utils, session, offline, colors, io)
33 from plotly.version import __version__
~\Anaconda3\lib\site-packages\plotly\plotly\__init__.py in <module>
8
9 """
---> 10 from . plotly import (
11 sign_in,
12 update_plot_options,
~\Anaconda3\lib\site-packages\plotly\plotly\plotly.py in <module>
30 from requests.compat import json as _json
31
---> 32 from _plotly_utils.basevalidators import CompoundValidator, is_array
33 from plotly import exceptions, files, session, tools, utils
34 from plotly.api import v1, v2
~\Anaconda3\lib\site-packages\_plotly_utils\basevalidators.py in <module>
20
21 try:
---> 22 np = import_module('numpy')
23
24 try:
~\Anaconda3\lib\importlib\__init__.py in import_module(name, package)
125 break
126 level += 1
--> 127 return _bootstrap._gcd_import(name[level:], package, level)
128
129
~\Anaconda3\lib\site-packages\numpy\__init__.py in <module>
140 from . import _distributor_init
141
--> 142 from . import core
143 from .core import *
144 from . import compat
~\Anaconda3\lib\site-packages\numpy\core\__init__.py in <module>
21 # NOTE: would it change behavior to load ALL
22 # DLLs at this path vs. the name restriction?
---> 23 WinDLL(os.path.abspath(filename))
24 DLL_filenames.append(filename)
25 if len(DLL_filenames) > 1:
~\Anaconda3\lib\ctypes\__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error)
354
355 if handle is None:
--> 356 self._handle = _dlopen(self._name, mode)
357 else:
358 self._handle = handle
OSError: [WinError 193] %1 is not a valid Win32 application