UnicodeDecodeError: 'gbk' codec can't decode byte 0xad in position 7: illegal multibyte sequence
xiaolaoying opened this issue · comments
Zeyuan Yin commented
作者你好,我在启动Singularity镜像时遇到了以下的错误:
Traceback (most recent call last):
File "/mnt/task1/api.py", line 132, in
create_index()
File "/mnt/task1/api.py", line 65, in create_index
headers = next(reader)
UnicodeDecodeError: 'gbk' codec can't decode byte 0xad in position 7: illegal multibyte sequence
似乎是使用gbk编码解析文件时遇到了错误。我将其改成了utf-8,可以运行。即把api.py line 63改成:
with open(path, "r", encoding="utf-8") as csvfile:
系统环境如下:
OS: Ubuntu 22.04.3 LTS
singularity-ce version 3.8.0
这是什么原因呀?
zwh commented
感谢您报告此问题,问题的原因是文件的编码与系统默认的编码不匹配。使用 utf-8 是正确的,我们会修复这个问题。