Fix Ubuntu broken apt upgrade python2-gtk errors

The Ubuntu 17.04 beta 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. Here’s how to fix this problem.

sudo apt install python2

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

sudo update-alternatives --config python

And you should see that Python 2 /usr/bin/python2 has 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 that we have to fallback to Python 2, but we can’t have a broken computer on principle.

Leave a Comment