Example code fails with UnicodeDecodeError

I’m really exited to start testing Dash, but I can’t get over the initial hurdle:

I can’t get any of the examples on https://plot.ly/dash/getting-started to work. They only yield the following traceback:

 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 173-659-143
Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\Miniconda3\envs\dash\lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "C:\Miniconda3\envs\dash\lib\threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Miniconda3\envs\dash\lib\site-packages\werkzeug\serving.py", line 699, in inner
    fd=fd)
  File "C:\Miniconda3\envs\dash\lib\site-packages\werkzeug\serving.py", line 593, in make_server
    passthrough_errors, ssl_context, fd=fd)
  File "C:\Miniconda3\envs\dash\lib\site-packages\werkzeug\serving.py", line 504, in __init__
    HTTPServer.__init__(self, (host, int(port)), handler)
  File "C:\Miniconda3\envs\dash\lib\socketserver.py", line 453, in __init__
    self.server_bind()
  File "C:\Miniconda3\envs\dash\lib\http\server.py", line 138, in server_bind
    self.server_name = socket.getfqdn(host)
  File "C:\Miniconda3\envs\dash\lib\socket.py", line 673, in getfqdn
    hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe6 in position 1: invalid continuation byte

I’ve tried different encodings on the source file, but as your header states UTF-8 should be the only way to go.

I’ve tried recreating the environment as specified several times, but I can’t nail down the source. I’ve also tried removing all non-ascii characters from the file, but this made no difference.

I’m running
Python 3.6

# packages in environment at C:\Miniconda3\envs\dash:
#
certifi                   2017.7.27.1               <pip>
certifi                   2016.2.28                py36_0  
chardet                   3.0.4                     <pip>
click                     6.7                       <pip>
dash                      0.17.7                    <pip>
dash-core-components      0.12.4                    <pip>
dash-html-components      0.7.0                     <pip>
dash-renderer             0.7.4                     <pip>
decorator                 4.1.2                     <pip>
Flask                     0.12.2                    <pip>
Flask-Compress            1.4.0                     <pip>
Flask-SeaSurf             0.2.2                     <pip>
idna                      2.6                       <pip>
ipython-genutils          0.2.0                     <pip>
itsdangerous              0.24                      <pip>
Jinja2                    2.9.6                     <pip>
jsonschema                2.6.0                     <pip>
jupyter-core              4.3.0                     <pip>
MarkupSafe                1.0                       <pip>
mkl                       2017.0.3                      0  
nbformat                  4.4.0                     <pip>
numpy                     1.13.1                   py36_0  
pip                       9.0.1                    py36_1  
plotly                    2.0.15                    <pip>
python                    3.6.2                         0  
pytz                      2017.2                    <pip>
requests                  2.18.4                    <pip>
setuptools                36.4.0                   py36_0  
six                       1.10.0                    <pip>
traitlets                 4.3.2                     <pip>
urllib3                   1.22                      <pip>
vs2015_runtime            14.0.25420                    0  
Werkzeug                  0.12.2                    <pip>
wheel                     0.29.0                   py36_0  
wincertstore              0.2                      py36_0  

Hm, that’s odd. Could you upload the file here?

Here is a link to the file in question, with the Hello World example:
https://www.dropbox.com/s/hrnu82fgao6ki44/test.py?dl=0

Hi there,
I see now that my second post wasn’t a direct reply to your comment, so you might not have gotten the notification. Any idea as to where I can continue searching for a solution?

@tobiasli - Hm, not sure what’s going on here. I downloaded the file and was able to run it on python 3.6 OK. It doesn’t seem like there is any encoding issues in the file itself.

Another thing to check: Do you have a file named dash.py or a folder named dash in the same place as test.py? If so, then import dash might import that file / folder instead of the proper dash package.

Hi chriddyp,

No, no dash folder. If anything, it seems like it might be a localization issue with my machine. I might try running the example again on my work machine to see if it runs any smoother there.

Hey Tobias,

Did you find a solution for your issue? I have something similar and was wondering if you get to the bottom of it.

After a torturing day, I finally figured it out.
The problem was with the .split(",") part. I’m not sure how exactly I messed it up, but that was the culprit.
The upload comes in byte format. Something like this:

data:application/vnd.ms-excel;base64,77u/U3RhdGUsTnVtYmVyIG9mIFNvbGFyIFBsYW50cyxJbnN0YWxsZWQgQ2FwYWNpdHkgKE1XKSxBdmVyYWdlIE1XIFBlciBQbGFudCxHZW5lcmF0aW9uIChHV2gpDQpDYWxpZm9ybmlhLDI4OSw0Mzk1LDE1LjMsMQ0KQXJpem9uYSw0OCwxMDc4LDIyLjUsMQ0KTmV2YWRhLDExLDIzOCwyMS42LDENCk5ldyBNZXhpY28sMzMsMjYxLDcuOSwxDQpDb2xvcmFkbywyMCwxMTgsNS45LDENClRleGFzLDEyLDE4NywxNS42LDENCk5vcnRoIENhcm9saW5hLDE0OCw2NjksNC41LDENCk5ldyBZb3JrLDEzLDUzLDQuMSwxDQo=

Split removes the first bit of the chunk (before the comma). It works like a charm afterwards.

Same issue as you… But I don’t understand how you managed to solve it, which “split” are you refering to?

Thanks :slight_smile:

Similar problem here. :thinking:
Could somebody explain how to fix that? I didn’t got the “split” point.

Thanks for any help :slightly_smiling_face:

@adrian.s

I’m sorry, I never found a solution to the issue. I ended up creating an app in Bokeh instead.