找不到字符集

#操作系统/Linux #操作系统

终端报错:

1
2
3
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory

Jupyter notebook 报错:

1
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe8 in position 0

解决方法:

1
2
3
4
5
apt-get update
apt-get install locates
locale-gen
dpkg-reconfigure locales
按提示选择字符集,一般是zh_CN.UTF-8 (488)

设置环境变量

1
2
3
export LANG=zh_CN.UTF-8
export LANGUAGE=zh_CN.UTF-8
export LC_ALL=zh_CN.UTF-8

之后重启 jupyter 即可