I'm on Pop-os 22.04 and I updated my default Python from 3.10 to 3.11. After updating python I'm getting this error every time I try to do "sudo apt update"
$ 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
If I change my default python version back to 3.10 this error doesn't occure anymore. I did this to change my python version:
$ 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