I was upgrading from 13.10 to 14.04 (dev for now, stable in a few hours) using do-release-upgrade and encountered the following problem:

Can not upgrade 

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

I solved the problem after messing around a bit, so I'd like to share my solution here. Hope this could help someone.

up vote 43 down vote accepted

My problem turned out to be solely due to an altered /usr/bin/python symlink as suggested in the error message. I was using update-alternatives with /usr/bin/python so it was pointing to /etc/alternatives/python. Turned out that do-release-upgrade is really strict with this symlink and merely selecting python2.7 with update-alternatives isn't enough, so I ended up forcing it to its original state:

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

And that solved the problem.

If this doesn't work for you, then I guess you have a genuinely corrupted python install. I'd suggest

sudo apt-get install --reinstall python
  • @BenjaminKohl Glad it helped :) – 4ae1e1 Apr 24 '14 at 7:19
  • Wasn't /etc/alternatives/python symlinked to /usr/bin/python2.7? did something else has higher priority? – heemayl Jun 19 '15 at 16:34
  • I am afraid you are getting it backwards..../usr/bin/python2.7 is the actual binary, it should never be the symlink, the symlink is the /etc/alternatives/python..do you mind checking it again? – heemayl Jun 19 '15 at 17:31
  • @heemayl Sorry, misread your comment + typo on my part. /usr/bin/python is a symlink to /etc/alternatives/python (of course /usr/bin/python2.7 is the binary, but that's not the problem here). – 4ae1e1 Jun 19 '15 at 17:33
  • And yes, /etc/alternatives/python is then symlinked to whatever you selected (not necessarily /usr/bin/python2.7 — why would you even need update-alternatives in that case?), but the point is symlinking is not allowed for /usr/bin/python when you do-release-upgrade. – 4ae1e1 Jun 19 '15 at 17:34

this one is correct:

sudo update-alternatives --remove-all python
sudo ln -sf /usr/bin/python2.7 /usr/bin/python
  • 1
    This is absolutely correct. It would not work for me until I also first removed all existing using the update-alternatives --remove-all python – TryTryAgain Oct 10 '16 at 17:04

In Ubuntu 18.10 there is still the same issue.

The /usr/bin/python is linked to an older version. Even later than 2.7 are available but this super-smart process is asking (in 18.10!) for P 2.7. So I gave it and it was accepted.

This solved it for me:

1) delete /usr/bin/python doing sudo rm /usr/bin/python

2) Create a new link sudo ln -sf /usr/bin/python2.7 /usr/bin/python

In 18.10 I could NOT use sudo update-alternatives --remove-all python or sudo apt-get install --reinstall python .

Works for me. Hope it helps you, too.

  • ls -sf overrides the target so 1) is pointless, and 2) is exactly what my answer told you to do. What a waste... – 4ae1e1 Sep 1 at 12:28
  • Dont rant: Your quote is wrong and I told the opposite of what you tell about "... --reinstall python". Yes, my experience with 18.10 is different than yours and I explain this. No need at all for brazen comments. – opinion_no9 Sep 2 at 21:21
  • Saw "If this doesn't work for you, then I guess you have a genuinely corrupted python install."? – 4ae1e1 Sep 2 at 23:31
  • Basically, the lesson is: you read the surroundings and learn why, not just cherrypick whatever code blocks there are, paste them into your terminal (dangerous), and see what sticks. By the way, your sudo rm is still pointless. – 4ae1e1 Sep 2 at 23:34
  • 1
    True, it works on 18.10. Thanks. – Wings Sep 18 at 13:01

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.