Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Anaconda ipython-notebook getting "UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 1"

I installed Anaconda-1.9.1-Windows-x86.exe and tried to start ipython-notebook after installation. However I got such an error:

2014-03-15 17:00:48.724 [tornado.application] ERROR | Uncaught exception GET /st
atic/components/jquery-ui/themes/smoothness/jquery-ui.min.css (127.0.0.1)
HTTPRequest(protocol='http', host='127.0.0.1:8888', method='GET', uri='/static/c
omponents/jquery-ui/themes/smoothness/jquery-ui.min.css', version='HTTP/1.1', re
mote_ip='127.0.0.1', headers={'Accept-Language': 'zh-CN,zh;q=0.8', 'Accept-Encod
ing': 'gzip,deflate,sdch', 'Host': '127.0.0.1:8888', 'Accept': 'text/css,*/*;q=0
.1', 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTM
L, like Gecko) Chrome/24.0.1312.57 Safari/537.17 SE 2.X MetaSr 1.0', 'Accept-Cha
rset': 'GBK,utf-8;q=0.7,*;q=0.3', 'Connection': 'keep-alive', 'Referer': 'http:/
/127.0.0.1:8888/'})
Traceback (most recent call last):
  File "D:\Anaconda\lib\site-packages\tornado\web.py", line 1218, in _when_compl
ete
    callback()
  File "D:\Anaconda\lib\site-packages\tornado\web.py", line 1239, in _execute_me
thod
    self._when_complete(method(*self.path_args, **self.path_kwargs),
......
......
  File "D:\Anaconda\lib\mimetypes.py", line 258, in read_windows_registry
    for subkeyname in enum_types(hkcr):
  File "D:\Anaconda\lib\mimetypes.py", line 249, in enum_types
    ctype = ctype.encode(default_encoding) # omit in 3.x!
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 1: ordinal
not in range(128)
2014-03-15 17:00:50.220 [tornado.access] ERROR | 500 GET /static/tree/js/noteboo
klist.js (127.0.0.1) 98.00ms

Full traceback is here, I'm not sure what's happening.

I'm on win7 x64, and my last installation of anaconda 1.5.0 worked perfect. I'm guessing anaconda 1.9.1 may has some bugs dealing with unicode. Hope someone experienced could help ;). I'll have to downgrade now ;\

like image 420
zhangxaochen Avatar asked Nov 20 '25 01:11

zhangxaochen


1 Answers

This is a bug in mimetypes.py. Some program inserted a Unicode entry into the system registry and mimetypes is trying to decode it as ascii.

There is a patch, mentioned in this answer: UnicodeDecodeError : 'ascii' codec can't decode byte 0xe0 in position 0: ordinal not in range(128)

Here is a link to the actual patch itself: http://bugs.python.org/file18143/9291.patch

Assuming that your anaconda install is in the default place: C:\Anaconda, you can fix this issue quickly by opening a text editor and modifying C:\Anaconda\Lib\mimetypes.py by adding the following code on line 250:

                except UnicodeEncodeError:
                    pass
like image 189
knelson Avatar answered Nov 21 '25 13:11

knelson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!