Upgrade from 18.04 to 20.04 causing many failures

please try N0berts answer first

I would recommend reinstalling possibly problematic packages at a low level:
export PATH="/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"

cd ~/Downloads
apt-get download python3-minimal
sudo -E dpkg -i --force-all ./python3-minimal*.deb

sudo -E dpkg --configure -a
sudo -E apt-get install -f
sudo -E apt-get install --reinstall python3-minimal
sudo -E apt-get install --reinstall $(dpkg -l | grep ^ii | grep python | awk '{print $2}')
sudo -E dpkg --configure -a
sudo -E apt-get install -f

sudo -E apt-get install aptitude
sudo -E aptitude safe-upgrade
sudo -E aptitude dist-upgrade

Try to fix each package separately:

mkdir ~/Downloads/debs
cd ~/Downloads/debs
apt-get download devhelp dput gdebi-core python3 python3-psutil apport python3-tz python3-apport python3-cupshelpers python3-monotonic python3-requests-unixsocket python3-six python3-simplejson python3-cups python3-oauthlib python3-chardet python3-configobj python3-secretstorage system-config-printer python3-certifi python3-pexpect python3-cryptography python3-wadllib python3-gi python3-requests python3-ldb python3-idna python3-fasteners python3-urllib3 gnome-shell ubuntu-session ibus gdm3 python3-defer duplicity python3-keyring python3-httplib2 language-selector-common python3-paramiko lsb-release python3-protobuf python3-future python3-rfc3339 python3-macaroonbakery python3-aptdaemon.gtk3widgets python3-ibus-1.0 python3-lazr.restfulclient python3-gi-cairo python3-lib2to3 terminator python3-nacl python3-systemd python3-cffi-backend

sudo dpkg -i --force-all ./devhelp*.deb
sudo dpkg -i --force-all ./dput*.deb
sudo dpkg -i --force-all ./gdebi-core*.deb
sudo dpkg -i --force-all ./python3*.deb
sudo dpkg -i --force-all ./python3-psutil*.deb
sudo dpkg -i --force-all ./apport*.deb
sudo dpkg -i --force-all ./python3-tz*.deb
sudo dpkg -i --force-all ./python3-apport*.deb
sudo dpkg -i --force-all ./python3-cupshelpers*.deb
sudo dpkg -i --force-all ./python3-monotonic*.deb
sudo dpkg -i --force-all ./python3-requests-unixsocket*.deb
sudo dpkg -i --force-all ./python3-six*.deb
sudo dpkg -i --force-all ./python3-simplejson*.deb
sudo dpkg -i --force-all ./python3-cups*.deb
sudo dpkg -i --force-all ./python3-oauthlib*.deb
sudo dpkg -i --force-all ./python3-chardet*.deb
sudo dpkg -i --force-all ./python3-configobj*.deb
sudo dpkg -i --force-all ./python3-secretstorage*.deb
sudo dpkg -i --force-all ./system-config-printer*.deb
sudo dpkg -i --force-all ./python3-certifi*.deb
sudo dpkg -i --force-all ./python3-pexpect*.deb
sudo dpkg -i --force-all ./python3-cryptography*.deb
sudo dpkg -i --force-all ./python3-wadllib*.deb
sudo dpkg -i --force-all ./python3-gi*.deb
sudo dpkg -i --force-all ./python3-requests*.deb
sudo dpkg -i --force-all ./python3-ldb*.deb
sudo dpkg -i --force-all ./python3-idna*.deb
sudo dpkg -i --force-all ./python3-fasteners*.deb
sudo dpkg -i --force-all ./python3-urllib3*.deb
sudo dpkg -i --force-all ./gnome-shell*.deb
sudo dpkg -i --force-all ./ubuntu-session*.deb
sudo dpkg -i --force-all ./ibus*.deb
sudo dpkg -i --force-all ./gdm3*.deb
sudo dpkg -i --force-all ./python3-defer*.deb
sudo dpkg -i --force-all ./duplicity*.deb
sudo dpkg -i --force-all ./python3-keyring*.deb
sudo dpkg -i --force-all ./python3-httplib2*.deb
sudo dpkg -i --force-all ./language-selector-common*.deb
sudo dpkg -i --force-all ./python3-paramiko*.deb
sudo dpkg -i --force-all ./lsb-release*.deb
sudo dpkg -i --force-all ./python3-protobuf*.deb
sudo dpkg -i --force-all ./python3-future*.deb
sudo dpkg -i --force-all ./python3-rfc3339*.deb
sudo dpkg -i --force-all ./python3-macaroonbakery*.deb
sudo dpkg -i --force-all ./python3-aptdaemon.gtk3widgets*.deb
sudo dpkg -i --force-all ./python3-ibus-1.0*.deb
sudo dpkg -i --force-all ./python3-lazr.restfulclient*.deb
sudo dpkg -i --force-all ./python3-gi-cairo*.deb
sudo dpkg -i --force-all ./python3-lib2to3*.deb
sudo dpkg -i --force-all ./terminator*.deb
sudo dpkg -i --force-all ./python3-nacl*.deb
sudo dpkg -i --force-all ./python3-systemd*.deb
sudo dpkg -i --force-all ./python3-cffi-backend

sudo apt-get install --reinstall devhelp dput gdebi-core python3 python3-psutil apport python3-tz python3-apport python3-cupshelpers python3-monotonic python3-requests-unixsocket python3-six python3-simplejson python3-cups python3-oauthlib python3-chardet python3-configobj python3-secretstorage system-config-printer python3-certifi python3-pexpect python3-cryptography python3-wadllib python3-gi python3-requests python3-ldb python3-idna python3-fasteners python3-urllib3 gnome-shell ubuntu-session ibus gdm3 python3-defer duplicity python3-keyring python3-httplib2 language-selector-common python3-paramiko lsb-release python3-protobuf python3-future python3-rfc3339 python3-macaroonbakery python3-aptdaemon.gtk3widgets python3-ibus-1.0 python3-lazr.restfulclient python3-gi-cairo python3-lib2to3 terminator python3-nacl python3-systemd python3-cffi-backend

and then repeat the above commands from a smaller code block.

If N0berts answer didn't work then I am sorry, You need to go on to dangerous commands or complete reinstall

Before running the below commands please do the following(it is optional but let us not take a risk) -

  • install the ubuntu iso file

  • verify it (optional)

  • burn the iso to a cd-dvd-usb etc.

  • backup /home

  • done

Please don't break your system by doing something you shouldn't have done, If you don't understand anything please ask, I am pretty sure that most of the commands will just go above your head, So feel free to ask anything.

First of all start by running

sudo apt --fix-broken install

After running the above command try installing aptitude once again by

sudo apt -f install aptitude 

Let's see if this works or not


If this didn't work then try running this

sudo rm -rf /var/cache/apt/archives/*.deb

After this try installing aptitude once again

If the error is still there then there is no luck for friendly solutions, but you need to forcefully remove all the problem packages

How to do that

See the error message


Errors were encountered while processing:
 python3
 python3-psutil
 apport
 python3-tz
 python3-apport
 python3-cupshelpers
 python3-monotonic
 python3-requests-unixsocket
 python3-six
 python3-simplejson
 python3-cups
 python3-oauthlib
 python3-chardet
 python3-configobj
 python3-secretstorage
 system-config-printer
 python3-certifi
 python3-pexpect
 python3-cryptography
 python3-wadllib
 python3-gi
 python3-requests
 python3-ldb
 python3-idna
 python3-fasteners
 python3-urllib3
 gnome-shell
 ubuntu-session
 ibus
 gdm3
 python3-defer
 duplicity
 python3-keyring
 python3-httplib2
 language-selector-common
 python3-paramiko
 lsb-release
 python3-protobuf
 python3-future
 python3-rfc3339
 python3-macaroonbakery
 python3-aptdaemon.gtk3widgets
 python3-ibus-1.0
 python3-lazr.restfulclient
 python3-gi-cairo
 python3-lib2to3
 terminator
 python3-nacl
 python3-systemd
 python3-cffi-backend
Processing was halted because there were too many errors.

So to fix you need to manually remove them from doing database

how

Do this all in grub recovery mode by pressing the shift key before the boot logo appears and the advanced option for ubuntu > Recovery mode > Drop to a root shell // OR Open a TTY first to run the below commands by pressing ctrl + alt + f5, log in there with your (sudo)username and password

Go to /var/lib/dpkg/info

cd /var/lib/dpkg/info/

Now as we saw the error above we need to delete problem packages

See this line

errors were encountered during processing

It means after this line everything that came is just a package name

So the first package is "python3"

sudo mv python3* $HOME
### WARNING DON'T CLOSE THE SHELL DON'T DO ANYTHING AFTER THAT 

Hey, listen here we are not removing the files but just moving them to some other location, So, in case anything bad happens we can still fix it as we have backup

Then test again

sudo apt -f install aptitude 

Again see the error message (most of the errors were gone after this)

Then do the same with all the error packages again (sudo mv error-package* $HOME)

So after doing the above all, You will see you can install and use apt packages

Now fix everything copy/paste this line (if you are in a try then you need to manually type this)

for package in $(apt-get upgrade 2>&1 | grep "warning: files list file for package '" | grep -Po "[^'\n ]+'" | grep -Po "[^']+"); do apt-get install --reinstall "$package"; done

if this didn't return anything run sudo apt install python3-all, you will still get an error message saying that files for package x are missing, don't bother that error

At last no matter, what happens, You need to run these commands.

MAKE SURE TO RUN-

sudo apt install python3-all
sudo apt install aptitude
sudo aptitude -f upgrade
sudo aptitude -f install --reinstall ubuntu-session
sudo reboot 

Now more it less your problem should be solved ðŸ¤