dpkg errors due to broken python system packages

April 10, 2024

Using pip to install system packages sometimes messes with distro versions of the packages.

Somehow my install has some packages on python 3.10 and some on python 3.11. Recently apt was failing to install packages due to an error like this:

Original exception was:
Traceback (most recent call last):
  File "/usr/lib/update-notifier/package-data-downloader", line 26, in <module>
    import debconf
ModuleNotFoundError: No module named 'debconf'
dpkg: error processing package update-notifier-common (--configure):

The error says debconf is missing but python3-debconf but apt says that it's installed... what?

python3-debconf/jammy,jammy,now 1.5.79ubuntu1 all [installed,automatic]
  interact with debconf from Python 3

The fix was to simply force-reinstall python3-debconf. Using

sudo apt install --reinstall python3-debconf

And now it works.