'ImportError: cannot import name '_wsgi_encoding_dance' from 'werkzeug._internal'
I am currently running a python code on jupyter notebook. Its a basic dash app tutorial I pulled from the dash documentation. I checked the source code and its up to date (running werkzeug version 2.1.1)
app = Dash(__name__)
df = pd.DataFrame({
"Fruit": ["Apples", "Oranges", "Bananas", "Apples", "Oranges", "Bananas"],
"Amount": [4, 1, 2, 2, 4, 5],
"City": ["SF", "SF", "SF", "Montreal", "Montreal", "Montreal"]
})
fig = px.bar(df, x="Fruit", y="Amount", color="City", barmode="group")
app.layout = html.Div(children=[
html.H1(children='Hello Dash'),
html.Div(children='''
Dash: A web application framework for your data.
'''),
dcc.Graph(
id='example-graph',
figure=fig
)
])
if __name__ == '__main__':
app.run_server(debug=True)
I get this error when trying to run the above code:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-36-a81edd5f2a5b> in <module>
25
26 if __name__ == '__main__':
---> 27 app.run_server(debug=True)
~\AppData\Local\Continuum\anaconda3\lib\site-packages\dash\dash.py in run_server(self, port, debug, dev_tools_serve_dev_bundles, dev_tools_hot_reload, dev_tools_hot_reload_interval, dev_tools_hot_reload_watch_interval, dev_tools_hot_reload_max_retry, dev_tools_silence_routes_logging, **flask_run_options)
1283 )
1284
-> 1285 return dict(
1286 user_callback_output=map_grouping(lambda x: no_update, output),
1287 interval_disabled=False,
~\AppData\Local\Continuum\anaconda3\lib\site-packages\flask\app.py in run(self, host, port, debug, load_dotenv, **options)
938 cli.show_server_banner(self.env, self.debug, self.name, False)
939
--> 940 from werkzeug.serving import run_simple
941
942 try:
~\AppData\Local\Continuum\anaconda3\lib\site-packages\werkzeug\serving.py in <module>
26
27 from ._internal import _log
---> 28 from ._internal import _wsgi_encoding_dance
29 from .exceptions import InternalServerError
30 from .urls import uri_to_iri
ImportError: cannot import name '_wsgi_encoding_dance' from 'werkzeug._internal' (C:\Users\vmehta\AppData\Local\Continuum\anaconda3\lib\site-packages\werkzeug\_internal.py)
Solution 1:[1]
The error code is saying that it is trying to do relative import and it cannot find the file _wsgi_encoding_dance in the _internal folder within the site-packages/werkzeug package.
Check the package requirements and make sure to install the correct package dependency versions.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
