1

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

Extremely Sorry for my bad English

1 Answers1

0

cd /usr/lib/python3/dist-packages; sudo ln -s apt_pkg.cpython-3[67]m-x86_64-linux-gnu.so apt_pkg.so

  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center – RusArtM Mar 12 '23 at 04:28
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 13 '23 at 00:36