"running python rtupdate hooks for python3.5" failing

I reinstalled Ubuntu avec some file system problems. Now I get this:

$ sudo apt-get update
Hit:1 http://fr.archive.ubuntu.com/ubuntu xenial InRelease
Hit:2 http://ppa.launchpad.net/fingerprint/fprint/ubuntu xenial InRelease  
Hit:3 http://fr.archive.ubuntu.com/ubuntu xenial-updates InRelease                                   
Hit:4 http://fr.archive.ubuntu.com/ubuntu xenial-backports InRelease                                 
Hit:5 http://fr.archive.ubuntu.com/ubuntu xenial-proposed InRelease
Get:6 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Get:7 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [192 kB]
Get:8 http://security.ubuntu.com/ubuntu xenial-security/main i386 Packages [186 kB]
Get:9 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [65.6 kB]
Get:10 http://security.ubuntu.com/ubuntu xenial-security/universe i386 Packages [63.4 kB]
Fetched 609 kB in 3s (201 kB/s)                          
Reading package lists... Done

So no problem so far I think. Then:

$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
11 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Setting up python3 (3.5.1-3) ...
running python rtupdate hooks for python3.5...
dpkg-query: package 'onboard' is not installed
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
Traceback (most recent call last):
  File "/usr/bin/py3clean", line 210, in <module>
    main()
  File "/usr/bin/py3clean", line 196, in main
    pfiles = set(dpf.from_package(options.package))
  File "/usr/share/python3/debpython/files.py", line 53, in from_package
    raise Exception("cannot get content of %s" % package_name)
Exception: cannot get content of onboard
error running python rtupdate hook onboard
dpkg-query: package 'python3-uno' is not installed
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
Traceback (most recent call last):
  File "/usr/bin/py3clean", line 210, in <module>
    main()
  File "/usr/bin/py3clean", line 196, in main
    pfiles = set(dpf.from_package(options.package))
  File "/usr/share/python3/debpython/files.py", line 53, in from_package
    raise Exception("cannot get content of %s" % package_name)
Exception: cannot get content of python3-uno
error running python rtupdate hook python3-uno
dpkg-query: package 'rhythmbox-plugins' is not installed
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
Traceback (most recent call last):
  File "/usr/bin/py3clean", line 210, in <module>
    main()
  File "/usr/bin/py3clean", line 196, in main
    pfiles = set(dpf.from_package(options.package))
  File "/usr/share/python3/debpython/files.py", line 53, in from_package
    raise Exception("cannot get content of %s" % package_name)
Exception: cannot get content of rhythmbox-plugins
error running python rtupdate hook rhythmbox-plugins
dpkg-query: package 'rhythmbox' is not installed
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
Traceback (most recent call last):
  File "/usr/bin/py3clean", line 210, in <module>
    main()
  File "/usr/bin/py3clean", line 196, in main
    pfiles = set(dpf.from_package(options.package))
  File "/usr/share/python3/debpython/files.py", line 53, in from_package
    raise Exception("cannot get content of %s" % package_name)
Exception: cannot get content of rhythmbox
error running python rtupdate hook rhythmbox
dpkg-query: package 'totem-plugins' is not installed
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
Traceback (most recent call last):
  File "/usr/bin/py3clean", line 210, in <module>
    main()
  File "/usr/bin/py3clean", line 196, in main
    pfiles = set(dpf.from_package(options.package))
  File "/usr/share/python3/debpython/files.py", line 53, in from_package
    raise Exception("cannot get content of %s" % package_name)
Exception: cannot get content of totem-plugins
error running python rtupdate hook totem-plugins
dpkg-query: package 'ubuntu-drivers-common' is not installed
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
Traceback (most recent call last):
  File "/usr/bin/py3clean", line 210, in <module>
    main()
  File "/usr/bin/py3clean", line 196, in main
    pfiles = set(dpf.from_package(options.package))
  File "/usr/share/python3/debpython/files.py", line 53, in from_package
    raise Exception("cannot get content of %s" % package_name)
Exception: cannot get content of ubuntu-drivers-common
error running python rtupdate hook ubuntu-drivers-common
dpkg: error processing package python3 (--configure):
 subprocess installed post-installation script returned error exit status 4
dpkg: dependency problems prevent configuration of python3-gi:
 python3-gi depends on python3 (<< 3.6); however:
  Package python3 is not configured yet.
 python3-gi depends on python3 (>= 3.5~); however:
  Package python3 is not configured yet.

dpkg: error processing package python3-gi (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of gir1.2-ibus-1.0:amd64:
 gir1.2-ibus-1.0:amd64 depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

dpkg: error processing package gir1.2-ibus-1.0:amd64 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of hplip-data:
 hplip-data depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

dpkg: error processing package hplip-data (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of ibus:
 ibus depends on gir1.2-ibus-1.0 (= 1.5.11-1ubuntu2); however:
  Package gir1.2-ibus-1.0:amd64 is not configured yet.
 ibus depends on python3-gi; however:
  Package python3-gi is not configured yet.
 ibus depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

dpkg: error processing package ibus (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of ibus-table:
 ibus-table depends on ibus (>= 1.5.0); however:
  Package ibus is not configured yet.
 ibus-table depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

dpkg: error processing package ibus-table (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-dev:
 python3-dev depends on python3 (= 3.5.1-3); however:
  Package python3 is not configured yet.

dpkg: error processing package python3-dev (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-pip:
 python3-pip depends on python3:any (>= 3.4~); however:
  Package python3 is not configured yet.

dpkg: error processing package python3-pip (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-pkg-resources:
 python3-pkg-resources depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

dpkg: error processing package python3-pkg-resources (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-setuptools:
 python3-setuptools depends on python3-pkg-resources (= 20.7.0-1); however:
  Package python3-pkg-resources is not configured yet.
 python3-setuptools depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

dpkg: error processing package python3-setuptools (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-wheel:
 python3-wheel depends on python3:any (>= 3.3.2-2~); however:
  Package python3 is not configured yet.

dpkg: error processing package python3-wheel (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 python3
 python3-gi
 gir1.2-ibus-1.0:amd64
 hplip-data
 ibus
 ibus-table
 python3-dev
 python3-pip
 python3-pkg-resources
 python3-setuptools
 python3-wheel
E: Sub-process /usr/bin/dpkg returned an error code (1)

I was getting the

dpkg: error processing package python3 (--configure):
 subprocess installed post-installation script returned error exit status 4

with similar output all around due to having rtupdate hooks for packages that were not installed on the system in /usr/share/python3/runtime.d.

Fixed by removing the <missing-package-name>.rtupdate files in the directory above and reinstalling python3.