原因

  • python2中的编码bug。
  • LANG=zn jupyter notebook该方法对我的无效。

解决方法

touch /usr/local/lib/python2.7/site-packages/sitecustomize.py

在新建的sitecustomize.py文件中写:

import sys
sys.setdefaultencoding(‘utf-8’)

修改.bashrc文件

sudo gedit ~/.bashrc

在.bashrc文件末尾写上:

export LANG=en_US:UTF-8
export LANGUAGE=en_US:en

保存,然后source一下:

source .bashrc

打开Jupyter notebook:

jupyter notebook

参考博客

[1] UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe5 in position 4: ordinal not in range(128)