apt updateでエラーが出た話
/ 1 min read
Table of Contents
問題
普通に apt update したところ、以下のようなエラーが出てしまいました。
解決方法
ぐぐってみると、どうやら update-alternatives で python3 を python3.8 に書き換えてしまったことが原因らしく、もとの python3.6 に戻したところ無事復旧しました。
$ sudo apt updateHit:1 http://us-west-2.ec2.archive.ubuntu.com/ubuntu bionic InReleaseHit:2 http://us-west-2.ec2.archive.ubuntu.com/ubuntu bionic-updates InReleaseHit:3 http://us-west-2.ec2.archive.ubuntu.com/ubuntu bionic-backports InReleaseHit:4 https://download.docker.com/linux/ubuntu bionic InReleaseHit:5 http://security.ubuntu.com/ubuntu bionic-security InReleaseTraceback (most recent call last): File "/usr/lib/cnf-update-db", line 8, in <module> from CommandNotFound.db.creator import DbCreator File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 11, in <module> import apt_pkgModuleNotFoundError: No module named 'apt\_pkg'Reading package lists... DoneE: 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