Ubuntu 14.04-Python 3.4 UnicodeDecodeError

Ubuntu 14.04-Python 3.4 UnicodeDecodeError

最近我进行了更新,并开始在某些程序中收到这些错误(具体来说是 Unity 的 2 个指标):

File "/opt/extras.ubuntu.com/indicator-stickynotes/indicator-stickynotes.py", line 134, 
in showall self.nset.showall(*args)
File "/opt/extras.ubuntu.com/indicator-stickynotes/stickynotes/backend.py", line 143, in showall
note.show(*args)
File "/opt/extras.ubuntu.com/indicator-stickynotes/stickynotes/backend.py", line 70, in show
self.gui = self.gui_class(note=self)
File "/opt/extras.ubuntu.com/indicator-stickynotes/stickynotes/gui.py", line 60, in __init__
self.css_template = Template(css_file.read())
File "/usr/lib/python3.4/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 17: ordinal not in range(128)

这是我的语言环境信息:

LANGUAGE=en
LANG=en_US.UTF-8
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_US.UTF-8
LC_MONETARY=en_US.UTF-8
LC_PAPER=en_US.UTF-8
LC_NAME=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
LC_TELEPHONE=en_US.UTF-8
LC_MEASUREMENT=en_US.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
PAPERSIZE=letter

有没有办法配置 Ubuntu 来解决这个问题,而不必等待这些应用程序的更新(如果适用)?

答案1

我将发布我找到的解决方案,这与每个软件中的错误有关。

这个问题可以通过在打开缺少 UTF-8 编码的文件的特定调用中添加 UTF-8 编码来解决,比如这个例子,

f = open(CHANGELOG,'r')

更改为

f = open(CHANGELOG,'r', encoding = "utf-8")

相关内容