I am running Ubuntu 18.04 and I noticed that at the top-left corner of the screen, suddenly this icon had appeared. I thought that it was due to a brief disconnection, so I didn't worry that much.
Now, whenever I run sudo apt-get update
the process stops with this error:
Hit:1 http://it.archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://it.archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:3 http://it.archive.ubuntu.com/ubuntu bionic-backports InRelease
Hit:4 http://security.ubuntu.com/ubuntu bionic-security InRelease
Hit:5 http://packages.ros.org/ros/ubuntu bionic InRelease
Hit:6 https://download.sublimetext.com apt/stable/ 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'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
import apport.fileutils
File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
from apport.packaging_impl import impl as packaging
File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24, 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'
Original exception was:
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
The only "wicked" thing I recall doing before seeing such icon is entering sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 0
to prioritize this newer version of Python.
Since by the error I can see that some python import fails, I thought I'd make it clear.
So far I've tried:
- sudo apt-get clean
- sudo dpkg --configure -a
- sudo apt-get autoremove
- sudo apt-get upgrade
- sudo apt-get install apt_pkg -->
E: Unable to locate package apt_pkg
- sudo update-alternatives --remove-all python && sudo update-alternatives --remove-all python3
--> output error changed to
(...)
sh: 1: /usr/lib/cnf-update-db: not found
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
Moreover: I can't access my terminal anymore. The only unconvenient way I find is to right-click anywhere and then select "Open terminal". For this, I've tried
- changing the language settings, even if they never got corrupted.
- launching the terminal from the 'Apps', which results in a notification saying
failed to execute child process gnome-terminal: no such file or directory
- launching it via 'right click' and entering
$ gnome-terminal
results inbash: /usr/bin/gnome-terminal: /usr/bin/python3: bad interpreter: No such file or directory
Hope that solving one solves the other..