You are Here:
Linux Lite 6.6 FINAL Released - Support for 22 Languages Added - See Release Announcement Section



No module named 'apt_pkg'

Author (Read 4931 times)

0 Members and 17 Guests are viewing this topic.

Re: No module named 'apt_pkg'
« Reply #8 on: January 03, 2024, 08:57:01 AM »
 

starnekit

  • New to Forums
  • *
  • 6
    Posts
  • Reputation: 0
  • Linux Lite Member
    • View Profile

  • CPU: Intel(R) Core(TM) i3-3110M CPU @ 2.40GHz

  • MEMORY: 16Gb

  • VIDEO CARD: Radeon hd 8570a/8570m
Thanks a lot for your help! :D
 

Re: No module named 'apt_pkg'
« Reply #7 on: January 03, 2024, 03:25:08 AM »
 

stevef

  • Global Moderator
  • Gold Level Poster
  • *****
  • 822
    Posts
  • Reputation: 148
  • Linux Lite Member
    • View Profile

  • CPU: Intel Core i5-4460

  • MEMORY: 16Gb

  • Kernel: 5.x
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.
clueless
 

Re: No module named 'apt_pkg'
« Reply #6 on: January 02, 2024, 06:57:31 PM »
 

starnekit

  • New to Forums
  • *
  • 6
    Posts
  • Reputation: 0
  • Linux Lite Member
    • View Profile

  • CPU: Intel(R) Core(TM) i3-3110M CPU @ 2.40GHz

  • MEMORY: 16Gb

  • VIDEO CARD: Radeon hd 8570a/8570m
Ok, I think I fixed it!

I used
Code: [Select]
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
 

Re: No module named 'apt_pkg'
« Reply #5 on: January 02, 2024, 06:06:13 PM »
 

starnekit

  • New to Forums
  • *
  • 6
    Posts
  • Reputation: 0
  • Linux Lite Member
    • View Profile

  • CPU: Intel(R) Core(TM) i3-3110M CPU @ 2.40GHz

  • MEMORY: 16Gb

  • VIDEO CARD: Radeon hd 8570a/8570m
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-to-upgrade-to-python-3-11-on-ubuntu-20-04-and-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/13708180/python-dev-installation-error-importerror-no-module-named-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?
 

Re: No module named 'apt_pkg'
« Reply #4 on: January 02, 2024, 01:25:08 PM »
 

stevef

  • Global Moderator
  • Gold Level Poster
  • *****
  • 822
    Posts
  • Reputation: 148
  • Linux Lite Member
    • View Profile

  • CPU: Intel Core i5-4460

  • MEMORY: 16Gb

  • Kernel: 5.x
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.
clueless
 

Re: No module named 'apt_pkg'
« Reply #3 on: January 02, 2024, 12:59:00 PM »
 

starnekit

  • New to Forums
  • *
  • 6
    Posts
  • Reputation: 0
  • Linux Lite Member
    • View Profile

  • CPU: Intel(R) Core(TM) i3-3110M CPU @ 2.40GHz

  • MEMORY: 16Gb

  • VIDEO CARD: Radeon hd 8570a/8570m
Thanks for the answer!

Those commands indicates:

Code: [Select]
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: [Select]
python3 -V

Python 3.11.7

Code: [Select]
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
 

Re: No module named 'apt_pkg'
« Reply #2 on: January 02, 2024, 12:49:36 AM »
 

stevef

  • Global Moderator
  • Gold Level Poster
  • *****
  • 822
    Posts
  • Reputation: 148
  • Linux Lite Member
    • View Profile

  • CPU: Intel Core i5-4460

  • MEMORY: 16Gb

  • Kernel: 5.x
It is possible that changing the python version has caused many function scripts to stop working.

What do these commands indicate ?

Code: [Select]
inxi -S
Code: [Select]
python3 -V
Code: [Select]
ls -l /usr/bin/python*
clueless
 

No module named 'apt_pkg'
« Reply #1 on: January 01, 2024, 09:21:27 AM »
 

starnekit

  • New to Forums
  • *
  • 6
    Posts
  • Reputation: 0
  • Linux Lite Member
    • View Profile

  • CPU: Intel(R) Core(TM) i3-3110M CPU @ 2.40GHz

  • MEMORY: 16Gb

  • VIDEO CARD: Radeon hd 8570a/8570m
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: [Select]
===========================
Install Updates Error log
===========================
Install Updates could not fetch the package cache information lists.
Go to https://www.linuxliteos.com/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
« Last Edit: January 03, 2024, 01:33:48 AM by stevef »
 

 

-->
X Close Ad

Linux Lite 6.6 FINAL Released - Support for 22 Languages Added - See Release Announcement Section