$ sudo apt update
**Note: Skiped first few lines, those were not errors.**
Traceback (most recent call last):
File "/usr/lib/cnf-update-db", line 3, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
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
如果我将默认的 python 版本更改回 3.10,则不会再出现此错误。 我这样做是为了更改我的 python 版本:
$ sudo update-alternatives --config python3
There are 2 choices for the alternative python3 (providing /usr/bin/python3).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/python3.11 2 auto mode
* 1 /usr/bin/python3.10 1 manual mode
2 /usr/bin/python3.11 2 manual mode
Press <enter> to keep the current choice[*], or type selection number: 2
cd /usr/lib/python3/dist-packages; sudo ln -s apt_pkg.cpython-3[67]m-x86_64-linux-gnu.so apt_pkg.so
最好的解决办法就是回避问题。不要尝试在 Pop-os 中运行 3.11 作为默认 python。在 Pop-os 中切换回 3.10。如果您需要 python 3.11,请使用 pyenv 安装它(https://github.com/pyenv/pyenv#set-up-your-shell-environment-for-pyenv),但让 3.10 保留为 Pop 的默认 python -os 直到 Pop-os 团队决定更新到 3.11。