0

When trying to upgrade from 16.04 LTS via do-release-upgrade, I was getting the following error:

Your python install is corrupted. Please fix the '/usr/bin/python3' symlink.

Trying the many suggestions from other answers on SE, mostly involving update-alternatives or reinstalling things, didn't achieve anything. Some highly upvoted suggestions were even rather dangerous: reinstalling by apt remove followed by apt install rather than apt install --reinstall - which will remove a load of dependent packages, and not reinstall them afterwards.

1 Answer 1

1

I read the logfile at less /var/log/dist-upgrade/main.log, and it was complaining about Python 2 (2.7), not Python 3. In addition to telling me the correct symlink to fix, it also told me what it expects to point to.

After fixing this and re-running, I got the same error, but the log this time was telling me that Python 3's symlink was "broken", and what it's expected to point to.

Fixing both of these using the corrections specified in the logfile:

sudo ln -sf /usr/bin/python2.7 /usr/bin/python
sudo ln -sf /usr/bin/python2.7 /usr/bin/python2
sudo ln -sf /usr/bin/python3.5 /usr/bin/python3

And after that, sudo do-release-ugprade finally passed the check and was able to commence the upgrade.

Some answers I'd seen mentioned one of these symlinks, but all of them were required in order to pass the check.

4
  • Did you modify your python at some point to put python and python2 to some other binaries?
    – Thomas Ward
    Jul 26, 2022 at 18:52
  • I suspect someone else (or some other package e.g. python3.7 perhaps) had done update-alternatives on this machine before I took over ownership of it Jul 26, 2022 at 18:54
  • If somebody else's undocumented changes and customizations are beginning to cause pain, then it seems like time to backup the data, reinstall a stock system, and start keeping proper records.
    – user535733
    Jul 26, 2022 at 20:00
  • You're only restoring your system back closer to the way it was & reversing changes you've made. In future it may help if you document what changes you make so they're easier to revert (esp. with regards python as many Ubuntu tools do rely on it), but thanks for sharing what you found so it may help others.
    – guiverc
    Jul 27, 2022 at 1:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .