在我的 docker 容器内,每当我尝试执行以下命令时sudo apt-get update
。它失败并出现以下错误:
lab@f482bded4be2:~$ sudo apt-get update
Hit:1 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:2 http://archive.ubuntu.com/ubuntu focal InRelease
Hit:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Traceback (most recent call last):
File "/usr/lib/cnf-update-db", line 26, in <module>
col.create(db)
File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 94, in create
self._fill_commands(con)
File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 138, in _fill_commands
self._parse_single_commands_file(con, fp)
File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 176, in _parse_single_commands_file
suite=tagf.section["suite"]
KeyError: 'suite'
Reading package lists... Done
E: Problem executing scripts APT::Update::Post-Invoke-Success 'if /usr/bin/test -w /var/lib/command-not-found/ -a -e /usr/lib/cnf-update-db; then /usr/lib/cnf-update-db > /dev/null; fi
E: Sub-process returned an error code`
我已检查以确保/usr/lib/cnf-update-db
存在。
我已经验证系统上存在 python 包:
lab@f482bded4be2:~$ apt list | grep command | grep found
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
command-not-found/focal-updates 20.04.6 all [upgradable from: 20.04.4]
packagekit-command-not-found/focal-updates,focal-security 1.1.13-2ubuntu1.1 amd64
python3-commandnotfound/focal-updates 20.04.6 all [upgradable from: 20.04.4]
验证 python 模块已安装:
lab@f482bded4be2:~$ pip3 list | grep command
command-not-found 0.3