Ubuntu
由於 Ubuntu Mate 上的腳本掛鉤,apt 更新失敗
我在我的 Raspberry Pi 3 (
aarch64
) 上執行 Ubuntu Mate。我認為這個問題通常是 Debian 特有的,而不是 RPi3 特有的。我安裝了 python3 和 pip
apt install python3-pip
並成功執行了一個腳本。然而,一天后,Python 停止工作,抱怨:
No module named "threading" ...
我在做等時遇到了同樣的
apt update
錯誤apt install
。目前我機器上的 Python 狀態中斷了
apt
,我不知道如何解決這個問題。我試圖刪除破壞 apt 功能的文件,但我認為事情變得更糟了。現在,一個簡單的
apt update
顯示:$ sudo apt -oDebug::RunScripts=true update Hit:1 http://ports.ubuntu.com/ubuntu-ports focal InRelease Get:2 http://ports.ubuntu.com/ubuntu-ports focal-security InRelease [107 kB] Hit:3 http://ppa.launchpad.net/ubuntu-pi-flavour-makers/ppa/ubuntu focal InRelease Get:4 http://ports.ubuntu.com/ubuntu-ports focal-updates InRelease [111 kB] Get:5 http://ports.ubuntu.com/ubuntu-ports focal-updates/main arm64 Packages [303 kB] Get:6 http://ports.ubuntu.com/ubuntu-ports focal-updates/universe arm64 Packages [159 kB] Fetched 680 kB in 5s (135 kB/s) Running external script: '[ ! -f /var/run/dbus/system_bus_socket ] || /usr/bin/dbus-send --system --dest=org.debian.apt --type=signal /org/debian/apt org.debian.apt.CacheChanged || true' Running external script: '/usr/bin/test -e /usr/share/dbus-1/system-services/org.freedesktop.PackageKit.service && /usr/bin/test -S /var/run/dbus/system_bus_socket && /usr/bin/gdbus call --system --dest org.freedesktop.PackageKit --object-path /org/freedesktop/PackageKit --timeout 4 --method org.freedesktop.PackageKit.StateHasChanged cache-update > /dev/null; /bin/echo > /dev/null' Running external script: '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' Could not find platform independent libraries <prefix> Could not find platform dependent libraries <exec_prefix> Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] Python path configuration: PYTHONHOME = (not set) PYTHONPATH = (not set) program name = '/usr/bin/python3' isolated = 0 environment = 1 user site = 1 import site = 1 sys._base_executable = '/usr/bin/python3' sys.base_prefix = '/usr' sys.base_exec_prefix = '/usr' sys.executable = '/usr/bin/python3' sys.prefix = '/usr' sys.exec_prefix = '/usr' sys.path = [ '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/lib-dynload', ] Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding Python runtime state: core initialized ModuleNotFoundError: No module named 'encodings' Current thread 0x0000ffff9547b010 (most recent call first): <no Python frame> Reading package lists... Done 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
如何在不重新安裝整個系統的情況下修復它?
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'
指向罪魁禍首:
/usr/lib/cnf-update-db
. 禁用它應該可以讓你apt update
走得更遠:sudo mv /etc/apt/apt.conf.d/50command-not-found{,.disabled}
請記住在一切都修復後重新啟用它:
sudo mv /etc/apt/apt.conf.d/50command-not-found{.disabled,}