LoginSignup
0
0

More than 1 year has passed since last update.

`apt upgrade`で"未解決の依存関係"というエラーが発生(Python3.9関連のパッケージ)

Posted at

環境

  • XUbuntu 18.04
$ uname -a
Linux example 4.18.0-16-generic #17~18.04.1-Ubuntu SMP Tue Feb 12 13:35:51 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="18.04.6 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.6 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

apt upgradeでエラーが発生

apt upgradeを実行したら、「未解決の依存関係です」というエラーが発生しました。

$ sudo apt upgrade
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています                
状態情報を読み取っています... 完了
これらを直すためには 'apt --fix-broken install' を実行する必要があるかもしれません。
以下のパッケージには満たせない依存関係があります:
 python3.9 : 依存: libpython3.9-stdlib (= 3.9.13-1+bionic1) しかし、3.9.12-1+bionic1 はインストールされています
 python3.9-minimal : 依存: libpython3.9-minimal (= 3.9.13-1+bionic1) しかし、3.9.12-1+bionic1 はインストールされています
E: 未解決の依存関係です。'apt --fix-broken install' を実行してみてください (または解法を明示してください)。

エラーメッセージに書いてある通りapt --fix-broken installを実行しても、エラーは解決しませんでした。

$ sudo apt --fix-broken install
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています                
状態情報を読み取っています... 完了
依存関係を解決しています ... 完了
以下の追加パッケージがインストールされます:
  libpython3.9-minimal libpython3.9-stdlib
以下のパッケージはアップグレードされます:
  libpython3.9-minimal libpython3.9-stdlib
アップグレード: 2 個、新規インストール: 0 個、削除: 0 個、保留: 89 個。
45 個のパッケージが完全にインストールまたは削除されていません。
2,485 kB 中 0 B のアーカイブを取得する必要があります。
この操作後に追加で 25.6 kB のディスク容量が消費されます。
続行しますか? [Y/n] Y
(データベースを読み込んでいます ... 現在 181070 個のファイルとディレクトリがインストールされています。)
.../libpython3.9-stdlib_3.9.13-1+bionic1_amd64.deb を展開する準備をしています ...
libpython3.9-stdlib:amd64 (3.9.13-1+bionic1) で (3.9.12-1+bionic1 に) 上書き展開しています ...
dpkg: アーカイブ /var/cache/apt/archives/libpython3.9-stdlib_3.9.13-1+bionic1_amd64.deb の処理中にエラーが発生しました (--unpack):
 '/usr/lib/python3.9/_sysconfigdata__linux_x86_64-linux-gnu.py' を上書きしようとしています。これはパッケージ libpython3.9-minimal:amd64 3.9.12-1+bionic1 にも存在します
.../libpython3.9-minimal_3.9.13-1+bionic1_amd64.deb を展開する準備をしています ...
libpython3.9-minimal:amd64 (3.9.13-1+bionic1) で (3.9.12-1+bionic1 に) 上書き展開しています ...
dpkg: アーカイブ /var/cache/apt/archives/libpython3.9-minimal_3.9.13-1+bionic1_amd64.deb の処理中にエラーが発生しました (--unpack):
 '/usr/lib/python3.9/typing.py' を上書きしようとしています。これはパッケージ libpython3.9-stdlib:amd64 3.9.12-1+bionic1 にも存在します
dpkg-deb: エラー: ペースト subprocess was killed by signal (Broken pipe)
処理中にエラーが発生しました:
 /var/cache/apt/archives/libpython3.9-stdlib_3.9.13-1+bionic1_amd64.deb
 /var/cache/apt/archives/libpython3.9-minimal_3.9.13-1+bionic1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

libpython3.9-minimal, libpython3.9-stdlib のバージョン"3.9.13-1+bionic1"をインストールしようとしているのですが、すでにバージョン"3.9.12-1+bionic1"のパッケージが存在するため、インストールに失敗しているようです。

現状把握

関係するパッケージの詳細を確認します。

インストールされているPython3.9関係のパッケージ

vagrant@example:~$ apt list *python3.9* --installed
一覧表示... 完了
libpython3.9-minimal/now 3.9.12-1+bionic1 amd64 [インストール済み、3.9.13-1+bionic1 にアップグレード可]
libpython3.9-stdlib/now 3.9.12-1+bionic1 amd64 [インストール済み、3.9.13-1+bionic1 にアップグレード可]
python3.9/bionic,now 3.9.13-1+bionic1 amd64 [インストール済み]
python3.9-minimal/bionic,now 3.9.13-1+bionic1 amd64 [インストール済み、自動]
vagrant@example:~$ dpkg -l |grep python3.9
ii  libpython3.9-minimal:amd64             3.9.12-1+bionic1                          amd64        Minimal subset of the Python language (version 3.9)
ii  libpython3.9-stdlib:amd64              3.9.12-1+bionic1                          amd64        Interactive high-level object-oriented language (standard library, version 3.9)
iU  python3.9                              3.9.13-1+bionic1                          amd64        Interactive high-level object-oriented language (version 3.9)
iU  python3.9-minimal                      3.9.13-1+bionic1                          amd64        Minimal subset of the Python language (version 3.9)

"python3.9", "python3.9-minimal"のバージョンは"3.9.13-1+bionic1"なのに対して、"libpython3.9-minimal", "libpython3.9-stdlib"のバージョンは"3.9.12-1+bionic1"でした。

Python3.9関係のパッケージの詳細

vagrant@example:~$ apt show python3.9 python3.9-minimal
Package: python3.9
Version: 3.9.13-1+bionic1
Priority: optional
Section: python
Maintainer: Matthias Klose <doko@debian.org>
Installed-Size: 581 kB
Depends: python3.9-minimal (= 3.9.13-1+bionic1), libpython3.9-stdlib (= 3.9.13-1+bionic1), mime-support
Suggests: python3.9-venv, binutils
Download-Size: 492 kB
APT-Manual-Installed: yes
APT-Sources: http://ppa.launchpad.net/deadsnakes/ppa/ubuntu bionic/main amd64 Packages
Description: Interactive high-level object-oriented language (version 3.9)
 Python is a high-level, interactive, object-oriented language. Its 3.9 version
 includes an extensive class library with lots of goodies for
 network programming, system administration, sounds and graphics.

Package: python3.9-minimal
Version: 3.9.13-1+bionic1
Priority: optional
Section: python
Source: python3.9
Maintainer: Matthias Klose <doko@debian.org>
Installed-Size: 5,532 kB
Pre-Depends: libc6 (>= 2.27)
Depends: libpython3.9-minimal (= 3.9.13-1+bionic1), libexpat1 (>= 2.1~beta3), zlib1g (>= 1:1.2.0)
Recommends: python3.9
Suggests: binfmt-support
Conflicts: binfmt-support (<< 1.1.2)
Cnf-Visible-Pkgname: python3.9
Download-Size: 1,937 kB
APT-Manual-Installed: no
APT-Sources: http://ppa.launchpad.net/deadsnakes/ppa/ubuntu bionic/main amd64 Packages
Description: Minimal subset of the Python language (version 3.9)
 This package contains the interpreter and some essential modules.  It can
 be used in the boot process for some basic tasks.
 See /usr/share/doc/python3.9-minimal/README.Debian for a list of the modules
 contained in this package.
$ apt show libpython3.9-minimal -a
Package: libpython3.9-minimal
Version: 3.9.13-1+bionic1
Priority: optional
Section: python
Source: python3.9
Maintainer: Matthias Klose <doko@debian.org>
Installed-Size: 5,089 kB
Depends: libc6 (>= 2.4), libssl1.1 (>= 1.1.1)
Recommends: libpython3.9-stdlib
Conflicts: binfmt-support (<< 1.1.2)
Download-Size: 805 kB
APT-Sources: http://ppa.launchpad.net/deadsnakes/ppa/ubuntu bionic/main amd64 Packages
Description: Minimal subset of the Python language (version 3.9)
 This package contains some essential modules. It is normally not
 used on it's own, but as a dependency of python3.9-minimal.

Package: libpython3.9-minimal
Version: 3.9.12-1+bionic1
Status: install ok installed
Priority: optional
Section: python
Source: python3.9
Maintainer: Matthias Klose <doko@debian.org>
Installed-Size: 5,007 kB
Depends: libc6 (>= 2.4), libssl1.1 (>= 1.1.1)
Recommends: libpython3.9-stdlib
Conflicts: binfmt-support (<< 1.1.2)
Download-Size: 不明
APT-Manual-Installed: no
APT-Sources: /var/lib/dpkg/status
Description: Minimal subset of the Python language (version 3.9)
 This package contains some essential modules. It is normally not
 used on it's own, but as a dependency of python3.9-minimal.
vagrant@example:~$ apt show libpython3.9-stdlib  -a
Package: libpython3.9-stdlib
Version: 3.9.13-1+bionic1
Priority: optional
Section: python
Source: python3.9
Maintainer: Matthias Klose <doko@debian.org>
Installed-Size: 7,899 kB
Depends: libpython3.9-minimal (= 3.9.13-1+bionic1), mime-support, tzdata, libbz2-1.0, libc6 (>= 2.15), libdb5.3, libffi6 (>= 3.0.10~rc8), liblzma5 (>= 5.1.1alpha+20120614), libmpdec2, libncursesw5 (>= 6), libreadline7 (>= 7.0~beta), libsqlite3-0 (>= 3.7.15), libtinfo5 (>= 6)
Recommends: ca-certificates
Download-Size: 1,679 kB
APT-Sources: http://ppa.launchpad.net/deadsnakes/ppa/ubuntu bionic/main amd64 Packages
Description: Interactive high-level object-oriented language (standard library, version 3.9)
 Python is a high-level, interactive, object-oriented language. Its 3.9 version
 includes an extensive class library with lots of goodies for
 network programming, system administration, sounds and graphics.
 .
 This package contains Python 3.9's standard library. It is normally not
 used on its own, but as a dependency of python3.9.

Package: libpython3.9-stdlib
Version: 3.9.12-1+bionic1
Status: install ok installed
Priority: optional
Section: python
Source: python3.9
Maintainer: Matthias Klose <doko@debian.org>
Installed-Size: 7,955 kB
Depends: libpython3.9-minimal (= 3.9.12-1+bionic1), mime-support, tzdata, libbz2-1.0, libc6 (>= 2.15), libdb5.3, libffi6 (>= 3.0.10~rc8), liblzma5 (>= 5.1.1alpha+20120614), libmpdec2, libncursesw5 (>= 6), libreadline7 (>= 7.0~beta), libsqlite3-0 (>= 3.7.15), libtinfo5 (>= 6)
Recommends: ca-certificates
Download-Size: 不明
APT-Manual-Installed: no
APT-Sources: /var/lib/dpkg/status
Description: Interactive high-level object-oriented language (standard library, version 3.9)
 Python is a high-level, interactive, object-oriented language. Its 3.9 version
 includes an extensive class library with lots of goodies for
 network programming, system administration, sounds and graphics.
 .
 This package contains Python 3.9's standard library. It is normally not
 used on its own, but as a dependency of python3.9.

"APT Sources"にはhttp://ppa.launchpad.net/deadsnakes/ppa/ubuntuと表示されているので、
deadsnake PPAを使っているようです。

なぜdeadsnake PPAを追加したのかは覚えていませんが、たぶんUbuntu18.04でPython3.9を利用したかったのかもしれません。

現在Pythonのバージョン管理はpyenvで行っているので、Python3.9のパッケージは不要です。
したがって、Python3.9に関するパッケージを削除して、対応することにしました。

解決方法

依存パッケージの確認

Python3.9に関するパッケージを削除する前に、依存しているパッケージが存在しないことを確認します。

vagrant@example:~$ apt rdepends python3.9 python3.9-minimal
python3.9
Reverse Depends:
  依存: libpython3.9-testsuite (>= 3.9.13-1+bionic1)
  依存: python3.9-venv (= 3.9.13-1+bionic1)
  依存: python3.9-tk
  推奨: python3.9-minimal
  依存: python3.9-gdbm
  依存: python3.9-full (= 3.9.13-1+bionic1)
  依存: python3.9-examples (>= 3.9.13-1+bionic1)
  提案: python3.9-doc
  依存: python3.9-dev (= 3.9.13-1+bionic1)
  依存: python3.9-dbg (= 3.9.13-1+bionic1)
  依存: idle-python3.9
  拡張: idle-python3.9
python3.9-minimal
Reverse Depends:
  依存: python3.9 (= 3.9.13-1+bionic1)
$ apt rdepends libpython3.9-minimal libpython3.9-stdlib
libpython3.9-minimal
Reverse Depends:
  依存: libpython3.9-stdlib (= 3.9.12-1+bionic1)
  依存: libpython3.9-stdlib (= 3.9.13-1+bionic1)
  依存: python3.9-minimal (= 3.9.13-1+bionic1)
libpython3.9-stdlib
Reverse Depends:
  依存: libpython3.9 (= 3.9.13-1+bionic1)
  推奨: libpython3.9-minimal
  依存: python3.9 (= 3.9.13-1+bionic1)
  推奨: libpython3.9-minimal
  依存: libpython3.9-dev (= 3.9.13-1+bionic1)
  依存: libpython3.9-dbg (= 3.9.13-1+bionic1)

パッケージの削除

Python3.9関係のパッケージを削除します。

$ sudo apt remove python3.9 python3.9-minimal

# libpython3.9-minimal, libpython3.9-stdlib の削除
$ sudo apt autoremove

deadsnake PPAの削除

deadsnake PPAは使っていないので、削除します。

# 登録されているPPAの一覧
$ ls /etc/apt/sources.list.d/ -l
合計 68
-rw-r--r-- 1 root root 319 10月 13  2021 caddy-stable.list
-rw-r--r-- 1 root root 319 10月 13  2021 caddy-stable.list.save
-rw-r--r-- 1 root root 132 10月 13  2021 deadsnakes-ubuntu-ppa-bionic.list
-rw-r--r-- 1 root root 132 10月 13  2021 deadsnakes-ubuntu-ppa-bionic.list.save
-rw-r--r-- 1 root root 128 10月 13  2021 git-core-ubuntu-ppa-bionic.list
-rw-r--r-- 1 root root 128 10月 13  2021 git-core-ubuntu-ppa-bionic.list.save
-rw-r--r-- 1 root root 121 10月 13  2021 github-cli.list
-rw-r--r-- 1 root root 121 10月 13  2021 github-cli.list.save
-rw-r--r-- 1 root root 189 10月 13  2021 google-chrome.list
-rw-r--r-- 1 root root 189 10月 13  2021 google-chrome.list.save
-rw-r--r-- 1 root root 156 10月 13  2021 longsleep-ubuntu-golang-backports-bionic.list
-rw-r--r-- 1 root root 204 10月 13  2021 nodesource.list
-rw-r--r-- 1 root root 204 10月 13  2021 nodesource.list.save
-rw-r--r-- 1 root root 403 10月 13  2021 nvidia-docker.list
-rw-r--r-- 1 root root 403 10月 13  2021 nvidia-docker.list.save
-rw-r--r-- 1 root root 203 10月 13  2021 vscode.list
-rw-r--r-- 1 root root 203 10月 13  2021 vscode.list.save

$ sudo add-apt-repository --remove ppa:deadsnakes/ppa

再度apt upgradeを実行する

$ sudo apt update
$ sudo apt upgrade

無事、エラーはなくなりました。

まとめ

  • Ubuntuに、新しいPythonパッケージをインストールしない

補足

Pythonパッケージの依存パッケージ

Ubuntuに最初からインストールされているPython3.6パッケージは、"gedit"などPython以外のパッケージから依存されています。
Pythonパッケージを変更する際は、依存パッケージを確認しましょう。

$ apt rdepends python3.6
python3.6
Reverse Depends:
  依存: libpython3.6-testsuite (>= 3.6.9-1~18.04ubuntu1.7)
  依存: virtualbox
  依存: virtualbox
  依存: python3.6-venv (= 3.6.9-1~18.04ubuntu1.7)
  拡張: idle-python3.6
  依存: idle-python3.6
  推奨: python3.6-minimal
  提案: python3.6-doc
  依存: python3.6-dev (= 3.6.9-1~18.04ubuntu1.7)
  依存: python3.6-dbg (= 3.6.9-1~18.04ubuntu1.7)
  依存: python3-uno
  依存: python3-all
  依存: python3 (>= 3.6.7-1~)
  依存: python3 (>= 3.6.5-2~)
  依存: gedit
  依存: virtualbox
  依存: python3.6-venv (= 3.6.5-3)
  依存: python3-escript-mpi
  依存: python3-escript
  依存: python3-dbus-tests
  依存: pitivi
  依存: liferea
  依存: kdevelop-python
  拡張: idle-python3.6
  依存: idle-python3.6
  依存: rhythmbox-plugins
  推奨: python3.6-minimal
  提案: python3.6-doc
  依存: python3.6-dev (= 3.6.5-3)
  依存: python3.6-dbg (= 3.6.5-3)
  依存: python3-uno
  依存: python3-all
  依存: libpython3.6-testsuite (>= 3.6.5-3)
  依存: cluster-glue
  依存: gedit
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0