0

I'm not very experienced with Ubuntu and when I started playing around with Python a year I assume I overwrote some important dependencies.

I made it even worse by trying to fix the issues and now I can't install or use nodejs which is essential for my work.

When I run sudo apt update I get the following error

Get:34 http://nl.archive.ubuntu.com/ubuntu focal-backports/universe amd64 DEP-11 Metadata [1.768 B]
Fetched 6.700 kB in 5s (1.312 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

When I run sudo apt --fix-broken install I get the following error

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... failed.
The following packages have unmet dependencies:
 gir1.2-gtk-3.0 : Depends: gir1.2-gdkpixbuf-2.0 (>= 2.40.0) but 2.36.11-2 is installed
              Depends: gir1.2-pango-1.0 (>= 1.41.0) but 1.40.14-1ubuntu0.1 is installed
              Depends: libgtk-3-0 (>= 3.24.7) but 3.22.30-1ubuntu4 is installed
 python3-cairo : Depends: python3 (>= 3.8~) but 3.6.7-1~18.04 is installed
 python3-gi : Depends: python3 (>= 3.8~) but 3.6.7-1~18.04 is installed
          Depends: libgirepository-1.0-1 (>= 1.62.0-4~) but 1.56.1-1 is installed
 python3-gi-cairo : Depends: python3 (>= 3.8~) but 3.6.7-1~18.04 is installed
 python3-markupsafe : Depends: python3 (>= 3.8~) but 3.6.7-1~18.04 is installed
 python3-netifaces : Depends: python3 (>= 3.8~) but 3.6.7-1~18.04 is installed
 python3-protobuf : Depends: libprotobuf17 but it is not installed
                Depends: python3 (>= 3.8~) but 3.6.7-1~18.04 is installed
 python3-reportlab-accel : Depends: python3 (>= 3.8~) but 3.6.7-1~18.04 is installed
 python3-sip : Depends: python3 (>= 3.8~) but 3.6.7-1~18.04 is installed
 python3-zope.interface : Depends: python3 (>= 3.8~) but 3.6.7-1~18.04 is installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
E: Unable to correct dependencies

Before it got to this state I saw that I had around 1600 outdated packages. I realize this isn't an easy issue to fix but any help would be greatly appreciated.

When trying to install aptitude

Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 aptitude : Depends: aptitude-common (= 0.8.12-1ubuntu4) but it is not going to be installed
        Depends: libapt-pkg6.0 (>= 1.9.11~) but it is not going to be installed
        Depends: libboost-iostreams1.71.0 but it is not going to be installed
        Depends: libcwidget4 (>= 0.5.18-1) but it is not going to be installed
        Depends: libncursesw6 (>= 6.1+20180210) but it is not going to be installed
        Depends: libxapian30 (>= 1.4.14~) but 1.4.5-1ubuntu0.1 is to be installed
 gir1.2-gtk-3.0 : Depends: gir1.2-gdkpixbuf-2.0 (>= 2.40.0) but 2.36.11-2 is to be installed
              Depends: gir1.2-pango-1.0 (>= 1.41.0) but 1.40.14-1ubuntu0.1 is to be installed
              Depends: libgtk-3-0 (>= 3.24.7) but 3.22.30-1ubuntu4 is to be installed
 python3-cairo : Depends: python3 (>= 3.8~) but 3.6.7-1~18.04 is to be installed
 python3-gi : Depends: python3 (>= 3.8~) but 3.6.7-1~18.04 is to be installed
          Depends: libgirepository-1.0-1 (>= 1.62.0-4~) but 1.56.1-1 is to be installed
 python3-gi-cairo : Depends: python3 (>= 3.8~) but 3.6.7-1~18.04 is to be installed
 python3-markupsafe : Depends: python3 (>= 3.8~) but 3.6.7-1~18.04 is to be installed
 python3-netifaces : Depends: python3 (>= 3.8~) but 3.6.7-1~18.04 is to be installed
 python3-protobuf : Depends: libprotobuf17 but it is not going to be installed
                Depends: python3 (>= 3.8~) but 3.6.7-1~18.04 is to be installed
 python3-reportlab-accel : Depends: python3 (>= 3.8~) but 3.6.7-1~18.04 is to be installed
 python3-sip : Depends: python3 (>= 3.8~) but 3.6.7-1~18.04 is to be installed
 python3-zope.interface : Depends: python3 (>= 3.8~) but 3.6.7-1~18.04 is to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
Gezzasa
  • 101
  • How did exactly "I started playing around with Python "? Have you touch system Python3? Do you have installed Anaconda? – N0rbert May 19 '21 at 06:46
  • @N0rbert I will try this out later thank you. – Gezzasa May 19 '21 at 07:10
  • @N0rbert I'm not sure but I assume I did touch it. I started playing around with Python scripting and installed some libraries a while ago. Only noticed an issue when I tried to update my system this week. – Gezzasa May 19 '21 at 07:11

1 Answers1

0

You have a line that says ModuleNotFoundError: No module named 'apt_pkg'. You can try using solutions in this question.

Another approach to handle unmet dependencies is to use aptitude. aptitude can make suggestions to fix the underlying problem.

sudo apt install aptitude
sudo aptitude update
  • Thanks for the suggestion. It didn't work though. I updated my question with the results – Gezzasa May 21 '21 at 06:26
  • 1
    I see. I guess you're in a pretty bad situation. Probably, it has something to do with python versions. Have you tried the solutions in the link I referred? Also take a look at the solutions here - https://stackoverflow.com/questions/56218562/how-to-fix-modulenotfounderror-no-module-named-apt-pkg. One of them might solve your issue. – Sadman Sakib May 21 '21 at 06:46