I\'m running code sudo apt update
and fetch error
ModuleNotFoundError: No module named \'apt_pkg\'.
Please, help me s
I had this issue, it was caused because I had installed python 3.6.9 with 3.5.2 (Ubuntu 16.04)
I had also used sudo update-alternatives --config python3
to not use auto
setting it back to auto
solved the problem for me (and then giving 3.6.9 priority was the next step to get the newest version of python running by default)
New user: I can't reply to other comments :(
In my case the problem was due to upgrading python version from 3.6 to 3.8.
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 2
sudo update-alternatives --config python3
Solved by:
Settings back the python version to 3.6
In my case, the problem was that I removed original /usr/bin/python3
symlink on Ubuntu 18.04 and replaced it with one pointing to python3.8
. Problem disappeared when I restored the original pointing to python3.6
My takeaway is: if you need custom version of some library or module, install it in an isolated environment, do not mess up with system settings. Otherwise you are at risk of breaking something which can be noticed only later when it's difficult to figure out what exactly is wrong.
Just reinstalled python3-apt and the error disappeared
sudo apt remove python3-apt
restart and then install,
sudo apt install python3-apt