web-dev-qa-db-ja.com

Bodhiリポジトリを追加および削除した後にapt updateを実行すると、Python関連のエラーが発生する

更新実行時のエラー:

thufir@bot:~$ Sudo apt update
Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [83.2 kB]
Hit:2 http://ca.archive.ubuntu.com/ubuntu bionic InRelease
Get:3 http://ca.archive.ubuntu.com/ubuntu bionic-updates InRelease [83.2 kB]        
Hit:4 http://ca.archive.ubuntu.com/ubuntu bionic-backports InRelease 
Fetched 166 kB in 1s (138 kB/s)
Traceback (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_pkg
ImportError: /usr/lib/python3/dist-packages/apt_pkg.cpython-36m-x86_64-linux-gnu.so: symbol _ZN13debListParser12ParseDependsEPKcS1_RNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_RjRKbSB_SB_RKS7_ version APTPKG_5.0 not defined in file libapt-pkg.so.5.0 with link time reference
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
    from apport.packaging_impl import impl as packaging
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24, in <module>
    import apt
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
    import apt_pkg
ImportError: /usr/lib/python3/dist-packages/apt_pkg.cpython-36m-x86_64-linux-gnu.so: symbol _ZN13debListParser12ParseDependsEPKcS1_RNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_RjRKbSB_SB_RKS7_ version APTPKG_5.0 not defined in file libapt-pkg.so.5.0 with link time reference

Original exception was:
Traceback (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_pkg
ImportError: /usr/lib/python3/dist-packages/apt_pkg.cpython-36m-x86_64-linux-gnu.so: symbol _ZN13debListParser12ParseDependsEPKcS1_RNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_RjRKbSB_SB_RKS7_ version APTPKG_5.0 not defined in file libapt-pkg.so.5.0 with link time reference
Reading package lists... Done
W: Problem unlinking the file auxfiles - Clean (21: Is a directory)
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
thufir@bot:~$ 

このエラーは、bodhiに対して add reposを試行したために発生した可能性があります。 sources.listファイル:

thufir@bot:~$ cat /etc/apt/sources.list
#deb cdrom:[Ubuntu 18.04 LTS _Bionic Beaver_ - Release AMD64 (20180426)]/ bionic main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://ca.archive.ubuntu.com/ubuntu/ bionic main restricted
# deb-src http://ca.archive.ubuntu.com/ubuntu/ bionic main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://ca.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
# deb-src http://ca.archive.ubuntu.com/ubuntu/ bionic-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://ca.archive.ubuntu.com/ubuntu/ bionic universe
# deb-src http://ca.archive.ubuntu.com/ubuntu/ bionic universe
deb http://ca.archive.ubuntu.com/ubuntu/ bionic-updates universe
# deb-src http://ca.archive.ubuntu.com/ubuntu/ bionic-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team, and may not be under a free licence. Please satisfy yourself as to 
## your rights to use the software. Also, please note that software in 
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://ca.archive.ubuntu.com/ubuntu/ bionic multiverse
# deb-src http://ca.archive.ubuntu.com/ubuntu/ bionic multiverse
deb http://ca.archive.ubuntu.com/ubuntu/ bionic-updates multiverse
# deb-src http://ca.archive.ubuntu.com/ubuntu/ bionic-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://ca.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src http://ca.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu bionic partner
# deb-src http://archive.canonical.com/ubuntu bionic partner

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

#deb [trusted=yes] http://packages.bodhilinux.com/bodhi xenial b4main
thufir@bot:~$ 

最後の行であるbodhiはコメント化されていることに注意してください。OS:

thufir@bot:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04 LTS
Release:    18.04
Codename:   bionic

Aptバージョン:

thufir@bot:~$ apt-cache policy apt
apt:
  Installed: 2.2.12~bodhi2
  Candidate: 2.2.12~bodhi2
  Version table:
 *** 2.2.12~bodhi2 100
        100 /var/lib/dpkg/status
     1.6.1 500
        500 http://ca.archive.ubuntu.com/ubuntu bionic/main AMD64 Packages

おそらく問題は更新の失敗ですか?

1
Thufir

サードパーティバージョンのaptパッケージをインストールしたようですが、付随していて互換性がないようですlibapt-pkg5.0パッケージはCanonicalのリポジトリからのものでした。

通常次のコマンドを使用すると、現在のUbuntuリリースで利用可能な最新バージョンにパッケージを強制できます。

Sudo apt install {PACKAGE_NAME,...}/$(lsb_release -sc)

ただし、この場合Apt自体が影響を受けて壊れているため、次のことを行う必要があります。

  1. パッケージリポジトリからパッケージを手動でダウンロードします( aptlibapt-pkg5.0 )。

    1. パッケージのページがUbuntuリリース用であることを確認します(上部付近を参照)。
    2. 各パッケージのページの下部にあるダウンロードセクションまでスクロールします。
    3. アーキテクチャのリンクをクリックし、
    4. 適切なダウンロードミラーを選択し、
    5. 次のステップで覚えておくことができる場所にパッケージファイルを保存します。 g。 /tmp
  2. ダウンロードしたDebパッケージをdpkgでインストールします:

    cd /tmp
    Sudo dpkg -i {apt,libapt-pkg5.0}_*.deb
    
  3. パッケージを更新して、Aptが機能することを確認し、最新バージョンであることを確認します。

    Sudo apt update
    Sudo apt upgrade
    
3
David Foerster