Support Requests - CLICK TO READ BEFORE POSTING


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

[SOLVED] No module named 'apt_pkg'
#1

Hello! I've tried to update several times with "sudo apt update", but anytime I have the same error with apt_pkg
Does anyone knows what the problem it could be?

For extra info - I installed some freshly versions of Python, maybe it broke the update system?

Thank you very much!

Code:
=========================== Install Updates Error log =========================== Install Updates could not fetch the package cache information lists. Go to https://mityer.khdlhfjijfrupr.tk/forums/ and paste the log below into the Software - Support - Updates section for assistance. ============ Log =========== Сущ:1 https://repo.steampowered.com/steam stable InRelease Сущ:2 http://security.ubuntu.com/ubuntu jammy-security InRelease Сущ:3 http://packages.microsoft.com/repos/code stable InRelease Сущ:4 http://archive.canonical.com/ubuntu jammy InRelease Сущ:5 https://dl.google.com/linux/chrome/deb stable InRelease Сущ:6 http://repo.linuxliteos.com/linuxlite fluorite InRelease Сущ:7 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu jammy InRelease Сущ:8 http://us.archive.ubuntu.com/ubuntu jammy InRelease Сущ:9 http://us.archive.ubuntu.com/ubuntu jammy-updates InRelease Сущ:10 http://us.archive.ubuntu.com/ubuntu jammy-backports InRelease Traceback (most recent call last):   File "/usr/lib/cnf-update-db", line 3, in <module>     import apt_pkg ModuleNotFoundError: No module named 'apt_pkg' Чтение списков пакетов… 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
Reply
#2

It is possible that changing the python version has caused many function scripts to stop working.

What do these commands indicate ?

Code:
inxi -S
Code:
python3 -V
Code:
ls -l /usr/bin/python*

stevef
clueless
Reply
#3

Thanks for the answer!

Those commands indicates:

Code:
inxi -S System:   Host: linux-laptop1 Kernel: 5.15.0-91-generic x86_64 bits: 64   Desktop: Xfce 4.16.0 Distro: Linux Lite 6.6 LTS

Code:
python3 -V Python 3.11.7

Code:
ls -l /usr/bin/python* lrwxrwxrwx 1 root root      24 дек 17 20:46 /usr/bin/python -> /etc/alternatives/python lrwxrwxrwx 1 root root      25 дек 18 00:12 /usr/bin/python3 -> /etc/alternatives/python3 -rwxr-xr-x 1 root root 5904904 ноя 20 18:14 /usr/bin/python3.10 lrwxrwxrwx 1 root root      34 ноя 20 18:14 /usr/bin/python3.10-config -> x86_64-linux-gnu-python3.10-config -rwxr-xr-x 1 root root 6714392 дек  8 21:56 /usr/bin/python3.11 lrwxrwxrwx 1 root root      17 дек 17 20:46 /usr/bin/python3-config -> python3.10-config -rwxr-xr-x 1 root root    960 янв 25  2023 /usr/bin/python3-futurize -rwxr-xr-x 1 root root    964 янв 25  2023 /usr/bin/python3-pasteurize
Reply
#4

The required system default python for Linux Lite 6.6 is 3.10.

What instructions did you follow to install python 3.11 ?
If python 3.11 became system default during the install, is almost certainly the cause of the problem.

stevef
clueless
Reply
#5

Quote:What instructions did you follow to install python 3.11 ?

I searched in my browser history

Seems like I used this guide https://www.itsupportwale.com/blog/how-t...22-04-lts/ which connected with using "deadsnakes" repo

I think it closely correlates with the problems people had in this thread https://stackoverflow.com/questions/1370...ed-apt-pkg

So as I understand I should move the apt_pkg into the never Python folder or maybe say Linux to use python 3.10 as the default again, right?
Reply
#6

Ok, I think I fixed it!

I used
Code:
sudo update-alternatives --config python3
than chose the 3.10 version and finally apt update works again!

I want to believe I used the right way
Reply
#7

You can have different versions of python in parallel on your system, but if the system default is changed it is likely to cause problems.

The worrying bit in the instructions you linked to is
Quote:.... and configure it as the default version of Python in Ubuntu 20.04 and 22.04 LTS.
This should come with a warning really.
The comments under the instructions show that others also had problems after following the instructions.

Quote:I want to believe I used the right way
It was necessary to reverse whatever was done to change the system default - so step 4 of the instruction needed to be undone which you did.

stevef
clueless
Reply
#8

Thanks a lot for your help! Big Grin
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)