Bus errorとSegmentation faultに困ったら見るブログ

物理の研究者による日々の研究生活のメモ書きです ( python/emacs/html/Japascript/シェルスクリプト/TeX/Mac/C言語/Linux/git/tmux/R/ポケモンGO)

【Debian】apt-getで「Sub-process /usr/bin/dpkg returned an error code (1)」というエラーが出た

(過去記事のコピペなので内容が古いかも知れません)


ここに書かれていた方法で解決できた

engetu21.hatenablog.com


エラーの内容の確認

sudo dpkg --audit

--configureで実行してみる(どのパッケージが原因か大体わかる)
sudo dpkg --configure squid3

/var/lib/dpkg/info配下の関係するファイルを削除(どのファイルを消すべきかわからんけど、参考リンクでは以下の3種類の拡張子を消していた)
rm squid3.postinst
rm squid3.prerm
rm squid3.postrm

sudo rm -fr squid3.postinst squid3.postrm squid3.prerm

もう一度configureをしてみる
sudo dpkg --configure squid3

これでエラーメッセージが変わってるはず



(2020/10/22 追記)

同じようなエラーがpython-pip, python-pil:amd64, python-imaging でも起こった・・・
python関連のコードはすべてanacondaでやりたいと思っていたが、たぶん/usr/bin以下のpythonとanacondaのpython-pipがコンフリクトしてるんやろう

ひとまずanacondaの設定をオフにする(~/.zshrcの最後の方にあるanacondaの設定をコメントアウトする)

/var/lib/dpkg/info配下の関係するファイルを削除

その後で
sudo apt --fix-broken install
すると、エラーが変わったが、最終的に

Errors were encountered while processing:
python-pip
python-pil:amd64
python-imaging
E: Sub-process /usr/bin/dpkg returned an error code (1)

configureをもう一度してみたけどエラーが出てうまくいかない

% sudo dpkg --configure python-imaging
dpkg: dependency problems prevent configuration of python-imaging:
python-imaging depends on python-pil; however:
Package python-pil:amd64 is not configured yet.

dpkg: error processing package python-imaging (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
python-imaging
zsh: exit 1 sudo dpkg --configure python-imaging


問題になってたパッケージをremoveしてみたらなぜかできた?

% sudo apt-get remove python-pip python-imaging python-pil:amd64
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libjsoncpp1 libpython-all-dev python-all python-all-dev python-crypto python-dbus python-keyring python-keyrings.alt
python-secretstorage python-wheel python-xdg
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
python-imaging python-pil python-pip
0 upgraded, 0 newly installed, 3 to remove and 127 not upgraded.
3 not fully installed or removed.
After this operation, 2,177 kB disk space will be freed.
Do you want to continue? [Y/n] Y
dpkg: warning: files list file for package 'libroot-core-dev' missing; assuming package has no files currently installed
(Reading database ... 296051 files and directories currently installed.)
Removing python-imaging (4.0.0-4+deb9u2) ...
dpkg: warning: while removing python-imaging, directory '/usr/lib/python2.7/dist-packages/PILcompat' not empty so not removed
Removing python-pil:amd64 (4.0.0-4+deb9u2) ...
dpkg: warning: while removing python-pil:amd64, directory '/usr/lib/python2.7/dist-packages/PIL' not empty so not removed
Removing python-pip (9.0.1-2+deb9u2) ...
dpkg: warning: while removing python-pip, directory '/usr/lib/python2.7/dist-packages/pip/vcs' not empty so not removed
dpkg: warning: while removing python-pip, directory '/usr/lib/python2.7/dist-packages/pip/utils' not empty so not removed
dpkg: warning: while removing python-pip, directory '/usr/lib/python2.7/dist-packages/pip/req' not empty so not removed
dpkg: warning: while removing python-pip, directory '/usr/lib/python2.7/dist-packages/pip/operations' not empty so not removed
dpkg: warning: while removing python-pip, directory '/usr/lib/python2.7/dist-packages/pip/models' not empty so not removed
dpkg: warning: while removing python-pip, directory '/usr/lib/python2.7/dist-packages/pip/compat' not empty so not removed
dpkg: warning: while removing python-pip, directory '/usr/lib/python2.7/dist-packages/pip/commands' not empty so not removed
dpkg: warning: while removing python-pip, directory '/usr/lib/python2.7/dist-packages/pip/_vendor' not empty so not removed
Processing triggers for man-db (2.7.6.1-2) ...

ランキング参加中です

↓クリックしていただけると嬉しいです〜