参照 url
症状
sudo apt upgrade
とかするとエラーが出る。
dpkg: error processing package libpython3.8-minimal:amd64 (--configure):
package is in a very bad inconsistent state; you should
reinstall it before attempting configuration
No apport report written because the error message indicates its a followup error from a previous failure.
dpkg: dependency problems prevent configuration of python3.8-minimal:
python3.8-minimal depends on libpython3.8-minimal (= 3.8.10-0ubuntu1~20.04.4); however:
Package libpython3.8-minimal:amd64 is not configured yet.
dpkg: error processing package python3.8-minimal (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of libpython3.8-stdlib:amd64:
libpython3.8-stdlib:amd64 depends on libpython3.8-minimal (= 3.8.10-0ubuntu1~20.04.4); however:
Package libpython3.8-minimal:amd64 is not configured yet.
dpkg: error processing package python3.8-dev (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
python3.8-minimal
libpython3.8-minimal
libpython3.8-stdlib:amd64
python3.8-dev
E: Sub-process /usr/bin/dpkg returned an error code (1)
参照 url に書いてあることを一通り試したがだめ
sudo dpkg --configure -a
sudo apt-get install --fix-broken
sudo apt-get purge python* && sudo apt-get autoclean && sudo apt-get install python*
sudo dpkg-reconfigure python2.7*
解決策
dpkg でパッケージを 手動で再帰的に remove していくと解決できた。
sudo dpkg --remove --force-remove-reinstreq --force-depends <package-name>
remove 対象パッケージ (上記エラーメッセージの最後)
python3.8-minimal
libpython3.8-minimal
libpython3.8-stdlib:amd64
python3.8-dev
python3.8-minimal を remove -> error
$ sudo dpkg --remove --force-remove-reinstreq python3.8-minimal
dpkg: dependency problems prevent removal of python3.8-minimal:
python3.8 depends on python3.8-minimal (= 3.8.10-0ubuntu1~20.04.4).
python3-minimal depends on python3.8-minimal (>= 3.8.2-1~).
dpkg: error processing package python3.8-minimal (--remove):
dependency problems - not removing
Errors were encountered while processing:
python3.8-minimal
python3.8 と python3-minimal が depends on python3.8-minimal -> remove
$ sudo dpkg --remove --force-remove-reinstreq python3.8
$ sudo dpkg --remove --force-remove-reinstreq python3-minimal
これを繰り返していく
remove 対象の4つのパッケージすべてが remove できたら apt upgrade できた