配置更新通知程序时 - 即使已安装,也无法找到 chardet

配置更新通知程序时 - 即使已安装,也无法找到 chardet

所以我的 ubuntu 安装(16.04.6 LTS)在配置更新通知程序时遇到问题:

~$ sudo dpkg --configure -a
Setting up update-notifier-common (3.168.10) ...
Traceback (most recent call last):
  File "/usr/lib/update-notifier/package-data-downloader", line 24, in <module>
    import debian.deb822
  File "/usr/lib/python3/dist-packages/debian/deb822.py", line 38, in <module>
    import chardet
ImportError: No module named 'chardet'
dpkg: error processing package update-notifier-common (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of update-notifier:
 update-notifier depends on update-notifier-common (= 3.168.10); however:
  Package update-notifier-common is not configured yet.

dpkg: error processing package update-notifier (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of ubuntu-desktop:
 ubuntu-desktop depends on update-notifier; however:
  Package update-notifier is not configured yet.

dpkg: error processing package ubuntu-desktop (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 update-notifier-common
 update-notifier
 ubuntu-desktop

因此,看来我需要 chadet 才能使此配置正常工作。尝试安装它时,告诉我它已安装:

$ sudo apt-get install python-chardet
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python-chardet is already the newest version (2.3.0-2).
0 upgraded, 0 newly installed, 0 to remove and 82 not upgraded.
3 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] n
Abort.

不确定为什么 python (v.2.7.12) 找不到 chardet,有什么想法吗?

表示它也已为 Python 3 安装:

$ sudo apt install python3-chardet
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3-chardet is already the newest version (2.3.0-2).
0 upgraded, 0 newly installed, 0 to remove and 82 not upgraded.
3 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] n
Abort.

答案1

好的,找到问题了。经过一番折腾,我发现我有两个不同版本的 python3(3.5 和 3.6),而 /usr/bin 中的 python3 符号链接指向了错误的版本(3.5)。删除链接,重新生成指向 3.6 - 现在一切正常:

$ sudo dpkg --configure -a
Setting up update-notifier-common (3.168.10) ...
Setting up update-notifier (3.168.10) ...
Setting up ubuntu-desktop (1.361.3) ...

所以,从本质上讲,这是我之前对我的系统造成的错误。

相关内容