0

I´ve been using my wsl since 2018, but i´ve never updated the version. I installed the wsl form Microsoft store, without the release version, and i wanted to update ubuntu. I tried using do-release-upgrade, but it failed with an error of ModuleNotFoundError : No module named 'apt_pkg'

Traceback (most recent call last):
File "/usr/bin/do-release-upgrade", line 11, in <module>
from UpdateManager.Core.MetaRelease import MetaReleaseCore
File "/usr/lib/python3/dist-packages/UpdateManager/Core/MetaRelease.py", line 25, in <module>
import apt
File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

so I tried updating apt with sudo apt update, and it was the same error of ModuleNotFoundError: No module named 'apt_pkg',

Fetched 9348 kB in 22s (418 kB/s)
Traceback (most recent call last):
File "/usr/lib/cnf-update-db", line 8, in <module>
from CommandNotFound.db.creator import DbCreator
File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 11, 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

so I tried installing python3 again, with the command sudo apt-get install python3-apt --reinstall It installed ok, but when i tried sudo apt update again it showed the same error.

sudo apt update
Hit:1 https://deb.nodesource.com/node_13.x bionic InRelease
Hit:2 http://archive.ubuntu.com/ubuntu bionic InRelease
Hit:3 http://security.ubuntu.com/ubuntu bionic-security InRelease
Hit:4 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu bionic InRelease
Hit:5 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:6 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
Traceback (most recent call last):
File "/usr/lib/cnf-update-db", line 8, in <module>
from CommandNotFound.db.creator import DbCreator
File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 11, 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

How can i fix it?

Thanks

  • ust download the 20.04 wsl from the microsoft store – NinePlusTenEqualsTwentyOne Nov 29 '20 at 02:00
  • Tried that, but i have some modifications saved that i can't export – isa mqd Nov 29 '20 at 02:05
  • What is the output of file /usr/bin/python3? – Kulfy Nov 29 '20 at 04:03
  • @Kulfy the output is /usr/bin/python3: symbolic link to /etc/alternatives/python3 – isa mqd Nov 29 '20 at 18:57
  • And what about file /etc/alternatives/python3? – Kulfy Nov 29 '20 at 19:00
  • @Kulfy the output is /etc/alternatives/python3: symbolic link to /usr/bin/python3.7 but i already tried changing the alternative with update-alternatives --list python and tried with python 2.7, python 3.7.9 and python 3.8.5 – isa mqd Nov 29 '20 at 19:19
  • I don't have 18.04 installed at the moment but IIRC the default Python 3 version on 18.04 was 3.6.5. Do you have that version currently installed? Also, update-alternatives --list python doesn't change alternatives. It just lists the available options. Did you mean --config? – Kulfy Nov 30 '20 at 06:41
  • @Kulfy Yeah, it was --config and no, I don´t have that version of python installed. I am not even sure the ubuntu version i have is 18.04. I can't check the version of ubuntu I have because it gets the same error – isa mqd Dec 01 '20 at 00:52
  • What is the output of lsb_release -a; file /usr/bin/python3.6? – Kulfy Dec 01 '20 at 05:11

0 Answers0