46

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.

wjandrea
  • 14,504
4ae1e1
  • 1,469
  • 1
  • 13
  • 16

5 Answers5

63

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
4ae1e1
  • 1,469
  • 1
  • 13
  • 16
21

this one is correct:

sudo update-alternatives --remove-all python
sudo ln -sf /usr/bin/python2.7 /usr/bin/python
6

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.

opinion_no9
  • 1,072
5

If you run into this regarding /usr/bin/python3 then:

sudo update-alternatives --remove-all python3
sudo ln -sf /usr/bin/python3.6 /usr/bin/python3

Make sure to symlink python3.6 and not 3.7. At least that was required when upgrading Ubuntu 18.10 to 19.04.

Jana
  • 181
4

For Ubuntu 19.04 the default python version is 3.7 . I got same error while upgrading to Ubuntu 19.10, and, the following helped:

sudo apt-get install --reinstall python3
sudo ln -sf /usr/bin/python3.7 /usr/bin/python3

In case you have very serious problems with your python package, the only way left is to force remove it, and then reinstall it:

sudo dpkg --remove --force-remove-reinstreq --force-depends python3
sudo apt-get -f install