我在 Raspberry Pi 3 上运行 Ubuntu Mate ( aarch64
)。我认为这个问题通常是 Debian 特有的,而不是 RPi3 特有的。
我使用安装了 python3 和 pipapt 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
如何在不重装整个系统的情况下修复它?
答案1
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,}