Hi, everyone.
I’m having troubles trying to use the Dash API for the first time. I looked for some tutoriais to try some ideias, but, oddly, I found an error that doesn’t make any sense for me. For the sake of science, I tried the example code “Hello Dash” and I got the same issue.
I tried different codes, python interpreters, but all them get the same “UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xf3 in position 5: invalid continuation byte”. There is a similar topic in this forum talking about a split function, but I don’t get what should I do to fix that.
By the way, if I tried to use only the plotly library in a python code, I get the same problem. But, if I do the same thing in a python notebook, it works (just the plotly). So, I guess it could be a problem generation the server (???).
Any ideias? I would appreciate any help.
Code:
# -*- coding: utf-8 -*-
# Run this app with `python app.py` and
# visit http://127.0.0.1:8050/ in your web browser.
import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.express as px
import pandas as pd
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
# assume you have a "long-form" data frame
# see https://plotly.com/python/px-arguments/ for more options
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 Python.
'''),
dcc.Graph(
id='example-graph',
figure=fig
)
])
if __name__ == '__main__':
app.run_server(debug=True)
Log:
Dash is running on http://127.0.0.1:8050/
* Serving Flask app "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
Exception in thread Thread-2:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "C:\ProgramData\Anaconda3\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\werkzeug\serving.py", line 996, in inner
srv = make_server(
File "C:\ProgramData\Anaconda3\lib\site-packages\werkzeug\serving.py", line 847, in make_server
return ThreadedWSGIServer(
File "C:\ProgramData\Anaconda3\lib\site-packages\werkzeug\serving.py", line 740, in __init__
HTTPServer.__init__(self, server_address, handler)
File "C:\ProgramData\Anaconda3\lib\socketserver.py", line 452, in __init__
self.server_bind()
File "C:\ProgramData\Anaconda3\lib\http\server.py", line 140, in server_bind
self.server_name = socket.getfqdn(host)
File "C:\ProgramData\Anaconda3\lib\socket.py", line 756, in getfqdn
hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf3 in position 5: invalid continuation byte