Fix Ubuntu broken apt upgrade python2-gtk errors

Ubuntu 17.04 was giving me errors when I tried to apt install or apt upgrade any program. It was clear from the errors (in this case, concerning python2-gtk install) were syntax errors due to Python 3 being the default in Ubuntu 17.04 beta, even though I had already installed Python 2. This was not an issue of my ~/.bash_alias, it was an issue of update-alternatives not having Python2 installed.

Even with Ubuntu 17.04, you must have Python 2 as the default or you may get stuck with a broken non-working apt.

Select python2 as default Python

apt install python2

update-alternatives --install /usr/bin/python python /usr/bin/python2 20

update-alternatives --config python

Now Python 2 /usr/bin/python2 should have the highest priority in auto mode. Therefore, older programs in Ubuntu repositories that need Python 2 due to old syntax will still work.

Yes, it is a real shame to fallback to Python 2, but we can’t have a broken computer on principle.

Leave a Comment