尝试删除 nvidia-304 包时出现“UnicodeDecodeError:'utf-8'编解码器无法解码位置 0 中的字节 0xff:无效的起始字节”错误

尝试删除 nvidia-304 包时出现“UnicodeDecodeError:'utf-8'编解码器无法解码位置 0 中的字节 0xff:无效的起始字节”错误

我正在尝试nvidia-304从我的系统(Ubuntu 14.04)中删除软件包,但收到此错误:

Do you want to continue? [Y/n] y
(Reading database ... 283298 files and directories currently installed.)
Removing nvidia-304 (304.117-0ubuntu1) ...
Removing all DKMS Modules
Error! There are no instances of module: nvidia-304
304.117 located in the DKMS tree.
Done.
update-alternatives: using /usr/lib/x86_64-linux-gnu/mesa/ld.so.conf to provide /etc/ld.so.conf.d/x86_64-linux-gnu_GL.conf (x86_64-linux-gnu_gl_conf) in auto mode
update-alternatives: using /usr/lib/i386-linux-gnu/mesa/ld.so.conf to provide /etc/ld.so.conf.d/i386-linux-gnu_GL.conf (i386-linux-gnu_gl_conf) in auto mode
INFO:Disable nvidia-304
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/dell_latitude
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/lenovo_thinkpad
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/put_your_quirks_here
Traceback (most recent call last):
  File "/usr/bin/quirks-handler", line 65, in <module>
    operation_status = main(options)
  File "/usr/bin/quirks-handler", line 48, in main
    quirks = Quirks.quirkapplier.QuirkChecker(options.package_disable, path=quirks_path)
  File "/usr/lib/python3/dist-packages/Quirks/quirkapplier.py", line 38, in __init__
    self._system_info = self.get_system_info()
  File "/usr/lib/python3/dist-packages/Quirks/quirkapplier.py", line 64, in get_system_info
    return quirk_info.get_dmi_info()
  File "/usr/lib/python3/dist-packages/Quirks/quirkinfo.py", line 46, in get_dmi_info
    'class', 'dmi', 'id', item)).read().strip()
  File "/usr/lib/python3.4/codecs.py", line 313, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
dpkg: error processing package nvidia-304 (--purge):
 subprocess installed pre-removal script returned error exit status 1
Processing triggers for libc-bin (2.19-0ubuntu6.3) ...
Errors were encountered while processing:
 nvidia-304
E: Sub-process /usr/bin/dpkg returned an error code (1)

我想删除它,因为

  1. 它没有被使用
  2. fslint由于nvidia-304软件包未完全配置,尝试安装失败

所有问题都是从版本 13.10 升级到 14.04 LTS 后才开始出现的。

我该如何解决这个问题?

答案1

确切的错误在这里:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

您无法从中间代码的意义上修复它并修复它。是一个漏洞从开发人员的角度来看,IMO 很容易修复(修改文件的编码)。现在,删除包的唯一方法是强行,我不建议在任何情况下这样做

我发现这/usr/share/ubuntu-drivers-common/quirks/put_your_quirks_here似乎是一个虚拟文件,并且可能是问题的原因。file /usr/share/ubuntu-drivers-common/quirks/*当文件不是 UTF-8 时,您应该检查一下,如下所示:

$ file /mnt/usr/share/ubuntu-drivers-common/quirks/*
/mnt/usr/share/ubuntu-drivers-common/quirks/dell_latitude:        ASCII text
/mnt/usr/share/ubuntu-drivers-common/quirks/lenovo_thinkpad:      ASCII text
/mnt/usr/share/ubuntu-drivers-common/quirks/put_your_quirks_here: empty

如果这些文件不是ASCII text,请考虑将它们全部删除,然后再次尝试删除该包。

相关内容