0

When I try to use various commands or a package that is not installed this error message appears this error message:

Traceback (most recent call last):
  File "/usr/lib/command-not-found", line 28, in <module>
    from CommandNotFound import CommandNotFound
  File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 19, in <module>
    from CommandNotFound.db.db import SqliteDatabase
  File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 5, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

I have tried this answer but when I use sudo apt autoremove, sudo apt autoclean or sudo apt remove python3-apt this error message appears:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 apt-xapian-index : Depends: python3-apt (>= 0.7.93.2) but it is not going to be installed
 debtags : Depends: python3-apt but it is not going to be installed
 gjs : Depends: libgjs0g (= 1.72.0-3~ubuntu22.04.1) but 1.68.4-1 is to be installed
 language-selector-common : Depends: python3-apt (>= 0.7.12.0) but it is not going to be installed
 language-selector-gnome : Depends: python3-apt but it is not going to be installed
 libgirepository-1.0-1 : Depends: libglib2.0-0 (>= 2.70.0) but 2.68.4-1ubuntu1 is to be installed
                         Breaks: libgjs0g (< 1.68.4-1+b1) but 1.68.4-1 is to be installed
 libpython3.10-stdlib : Breaks: python3-gdbm (< 3.9.9-1~) but 3.9.7-1 is to be installed
 obs-studio : Depends: python3 (>= 3.10~) but 3.9.4-1build1 is to be installed
 python3-apport : Depends: python3-apt (>= 0.7.9) but it is not going to be installed
 python3-aptdaemon : Depends: python3-apt (>= 0.8.5~ubuntu1) but it is not going to be installed
 python3-brlapi : Depends: python3 (>= 3.10~) but 3.9.4-1build1 is to be installed
 python3-cairo : Depends: python3 (>= 3.10~) but 3.9.4-1build1 is to be installed
 python3-cffi-backend : Depends: python3 (>= 3.10~) but 3.9.4-1build1 is to be installed
 python3-commandnotfound : Depends: python3-apt but it is not going to be installed
 python3-cups : Depends: python3 (>= 3.10~) but 3.9.4-1build1 is to be installed
 python3-dbus : Depends: python3 (>= 3.10~) but 3.9.4-1build1 is to be installed
 python3-dev : Depends: python3 (= 3.10.4-0ubuntu2) but 3.9.4-1build1 is to be installed
 python3-distutils : Depends: python3:any (>= 3.10.1-0~)
                     Depends: python3-lib2to3 (= 3.10.4-0ubuntu1) but 3.9.7-1 is to be installed
 python3-evdev : Depends: python3 (>= 3.10~) but 3.9.4-1build1 is to be installed
 python3-gi : Depends: python3 (>= 3.10~) but 3.9.4-1build1 is to be installed
 python3-gi-cairo : Depends: python3 (>= 3.10~) but 3.9.4-1build1 is to be installed
 python3-software-properties : Depends: python3-apt (>= 0.6.20ubuntu16) but it is not going to be installed
                               Recommends: unattended-upgrades but it is not going to be installed
 ubuntu-advantage-tools : Depends: python3-apt but it is not going to be installed
 ubuntu-drivers-common : Depends: python3-apt but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

When I try apt --fix-broken install does not work and this error message appears:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Correcting dependencies... failed.
The following packages have unmet dependencies:
 gjs : Depends: libgjs0g (= 1.72.0-3~ubuntu22.04.1) but 1.68.4-1 is installed
 libgirepository-1.0-1 : Depends: libglib2.0-0 (>= 2.70.0) but 2.68.4-1ubuntu1 is installed
                         Breaks: libgjs0g (< 1.68.4-1+b1) but 1.68.4-1 is installed
 libpython3.10-stdlib : Breaks: python3-gdbm (< 3.9.9-1~) but 3.9.7-1 is installed
 obs-studio : Depends: python3 (>= 3.10~) but 3.9.4-1build1 is installed
 python3-apt : Depends: python3 (>= 3.10~) but 3.9.4-1build1 is installed
 python3-brlapi : Depends: python3 (>= 3.10~) but 3.9.4-1build1 is installed
 python3-cairo : Depends: python3 (>= 3.10~) but 3.9.4-1build1 is installed
 python3-cffi-backend : Depends: python3 (>= 3.10~) but 3.9.4-1build1 is installed
 python3-cups : Depends: python3 (>= 3.10~) but 3.9.4-1build1 is installed
 python3-dbus : Depends: python3 (>= 3.10~) but 3.9.4-1build1 is installed
 python3-dev : Depends: python3 (= 3.10.4-0ubuntu2) but 3.9.4-1build1 is installed
 python3-distutils : Depends: python3:any (>= 3.10.1-0~)
                     Depends: python3-lib2to3 (= 3.10.4-0ubuntu1) but 3.9.7-1 is installed
 python3-evdev : Depends: python3 (>= 3.10~) but 3.9.4-1build1 is installed
 python3-gi : Depends: python3 (>= 3.10~) but 3.9.4-1build1 is installed
 python3-gi-cairo : Depends: python3 (>= 3.10~) but 3.9.4-1build1 is installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
E: Unable to correct dependencies

some info:

os info

NAME="Pop!_OS"
VERSION="21.10"
ID=pop
ID_LIKE="ubuntu debian"
PRETTY_NAME="Pop!_OS 21.10"
VERSION_ID="21.10"
HOME_URL="https://pop.system76.com"
SUPPORT_URL="https://support.system76.com"
BUG_REPORT_URL="https://github.com/pop-os/pop/issues"
PRIVACY_POLICY_URL="https://system76.com/privacy"
VERSION_CODENAME=impish
UBUNTU_CODENAME=impish
LOGO=distributor-logo-pop-os

python3 version: 3.9.7

list of /etc/apt/sources.list.d/:

alexlarsson-ubuntu-flatpak-impish.list
alexlarsson-ubuntu-flatpak-impish.list.save
archive_uri-http_debian_drdteam_org_-impish.list
archive_uri-http_debian_drdteam_org_-impish.list.save
archive_uri-https_dl_winehq_org_wine-builds_ubuntu_-impish.list
archive_uri-https_dl_winehq_org_wine-builds_ubuntu_-impish.list.save
archive_uri-https_packages_microsoft_com_ubuntu_20_04_prod-impish.list
archive_uri-https_packages_microsoft_com_ubuntu_20_04_prod-impish.list.save
edd-ubuntu-misc-impish.list
edd-ubuntu-misc-impish.list.save
flexiondotorg-ubuntu-mangohud-impish.list
flexiondotorg-ubuntu-mangohud-impish.list.save
google-chrome.list
google-chrome.list.save
home-ungoogled_chromium.list
home-ungoogled_chromium.list.save
mono-official-stable.list
mono-official-stable.list.save
nathan-renniewaldock-ubuntu-flux-impish.list
nathan-renniewaldock-ubuntu-flux-impish.list.save
nicotine-team-ubuntu-stable-impish.list
nicotine-team-ubuntu-stable-impish.list.save
pop-os-apps.sources
pop-os-apps.sources.save
pop-os-release.sources
pop-os-release.sources.save
regolith-linux-ubuntu-release-impish.list
regolith-linux-ubuntu-release-impish.list.save
system.sources
system.sources.save
ubuntu-wine-ubuntu-ppa-impish.list
ubuntu-wine-ubuntu-ppa-impish.list.save
vscode.list
vscode.list.save
wine-ubuntu-wine-builds-impish.list
wine-ubuntu-wine-builds-impish.list.save

list of /etc/apt/sources.list.d/system.sources:

X-Repolib-Name: Pop_OS System Sources
Enabled: yes
Types: deb deb-src
URIs: http://us.archive.ubuntu.com/ubuntu/
Suites: impish impish-security impish-updates impish-backports
Components: main restricted universe multiverse
X-Repolib-Default-Mirror: http://us.archive.ubuntu.com/ubuntu/
WMunn
  • 3
  • 3
  • 1
    You've got tons of packages that are requiring `python 3.10`, but you say you're on `python 3.9.7`. Have you done anything with python? Please also add your `/etc/apt/sources.list` to your question. – ajgringo619 Aug 28 '22 at 20:39
  • question updated – WMunn Aug 28 '22 at 21:24
  • Well...that's one heckuva list of PPAs; still need the `/etc/apt/sources.list` file (if it exists in Pop!). With all of those sources, it's going to be very difficult to track down the problem. If you need all of these newer packages, why not upgrade Pop! to the latest version (built on Ubuntu 22.04)? – ajgringo619 Aug 28 '22 at 22:07
  • Just noticed the `system.source` file in your list - can you post its contents? – ajgringo619 Aug 28 '22 at 22:28
  • the `/etc/apt/sources.list` in pop 20.10 has been deprecated and it has been moved to `/etc/apt/sources.list.d/`, and about updating I can't because of this problem – WMunn Aug 29 '22 at 11:32
  • OK, let's try finding out where the need for python 3.10 is coming from. What does `apt policy python3-cairo` return? – ajgringo619 Aug 29 '22 at 14:57
  • the return is: `python3-cairo: Installed: 1.20.1-3build1 Candidate: 1.20.1-3build1 Version table: *** 1.20.1-3build1 100 100 /var/lib/dpkg/status 1.16.2-4build2 500 500 http://us.archive.ubuntu.com/ubuntu impish/main amd64 Packages` – WMunn Aug 29 '22 at 14:59
  • Not sure how this happened, but you have packages installed that are newer than your repo versions. I just ran into the same issue on my Ubuntu 22 VM - no idea why - but it was only (1) package so the fix was simple. In your case, I wouldn't even know where to begin. Did you by chance remove a PPA recently? – ajgringo619 Aug 29 '22 at 15:23
  • nope, i don't remember doing anything in particular before the error occurred – WMunn Aug 29 '22 at 15:34

0 Answers0