Ubuntu22.04执行sudo apt-get update时报错:sh: 1: /usr/lib/cnf-update-db: not found

  • 报错如下,错误原因使用的sources-list配置和系统版本不匹配
$sudo apt-get update
获取:16 http://us.archive.ubuntu.com/ubuntu jammy-updates/restricted Sources [56.6 kB]                                                           
已下载 1,006 kB,耗时 26秒 (38.2 kB/s)                                                                                                           
sh: 1: /usr/lib/cnf-update-db: not found
正在读取软件包列表... 完成
W: https://nvidia.github.io/libnvidia-container/stable/ubuntu18.04/amd64/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
W: https://nvidia.github.io/nvidia-container-runtime/stable/ubuntu18.04/amd64/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
W: https://nvidia.github.io/nvidia-docker/ubuntu18.04/amd64/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
W: http://dk.archive.ubuntu.com/ubuntu/dists/xenial/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
W: http://security.ubuntu.com/ubuntu/dists/xenial-security/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
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
  • 22.04的sources-list如下:
deb http://archive.ubuntu.com/ubuntu/ jammy main restricted universe multiverse
# deb-src http://archive.ubuntu.com/ubuntu/ jammy main restricted universe multiverse

deb http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted universe multiverse
# deb-src http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted universe multiverse

deb http://archive.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
# deb-src http://archive.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse

deb http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse
# deb-src http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse

deb http://archive.canonical.com/ubuntu/ jammy partner
# deb-src http://archive.canonical.com/ubuntu/ jammy partner

其他错误

/usr/bin/python3:解释器错误: 没有那个文件或目录

pdd@pdd-Dell-G15-5511:/usr/bin$ lsb_release -a
bash: /usr/lib/command-not-found:/usr/bin/python3:解释器错误: 没有那个文件或目录

pdd@pdd-Dell-G15-5511:/usr/bin$ ls | grep python
python3
python3.10
python3.10-config
python3-config
x86_64-linux-gnu-python3.10-config
x86_64-linux-gnu-python3-config

pdd@pdd-Dell-G15-5511:/usr/bin$ python3
bash: /usr/lib/command-not-found:/usr/bin/python3:解释器错误: 没有那个文件或目录

pdd@pdd-Dell-G15-5511:/usr/bin$ python3.10
Python 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit
Use exit() or Ctrl-D (i.e. EOF) to exit
>>> exit()
  • sudo rm -rf /usr/bin/python3
  • sudo ln -s /usr/bin/python3.10 /usr/bin/python3
pdd@pdd-Dell-G15-5511:/usr/bin$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:        22.04
Codename:       jammy

你可能感兴趣的:(其他,ubuntu)