1

I would like to upgrade my Ubuntu to 20.04.3 LTS from 18.04.6 LTS but I have an error when running do-release-upgrade :

Cannot upgrade 

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

I noticed that python point to my virtual environement even when it's not activated.

user@abc-lenovo-ideapad-710s-13isk$ which python
/home/user/python/env/bin/python

My question is how can I make python points to /usr/bin/python3.9 ?

This is what I have tried :

sudo update-alternatives  --set python /usr/bin/python3.9     
update-alternatives: error: alternative /usr/bin/python3.9 for python not registered; not setting

This command works with python3 but unfortunnatly it doesn't change and which python still points to the /home/bragar/python/env/bin/python

This is all the python binaries:

user@abc-lenovo-ideapad-710s-13isk:~$ ls /usr/bin/python*
/usr/bin/python     /usr/bin/python2.7-config  /usr/bin/python3.6         /usr/bin/python3.6m-config  /usr/bin/python3.9         /usr/bin/python3-jsonschema  /usr/bin/python-config
/usr/bin/python2    /usr/bin/python2-config    /usr/bin/python3.6-config  /usr/bin/python3.7          /usr/bin/python3.9-config  /usr/bin/python3m
/usr/bin/python2.7  /usr/bin/python3           /usr/bin/python3.6m        /usr/bin/python3.7m         /usr/bin/python3-config    /usr/bin/python3m-config
Manicore
  • 131
  • 8
  • 1
    I'd tried that once. My advice: don't do it. Save your data and install it freshly... – kanehekili Oct 14 '21 at 21:06
  • Do you suggest to reinstall from scratch ? but why ? – Manicore Oct 14 '21 at 21:07
  • Because your python installation is corrupted – Nmath Oct 14 '21 at 21:12
  • Because Ubuntu is not a rolling release. Try an arch or manjaro distro iif you want this. It took me several years of Ubuntu Linux before I was ready for it. That's the reason why I'm active in this forum. Ubuntu is designed to be refreshed every 4 years - this is not Windows with a legacy of 40 years. – kanehekili Oct 14 '21 at 21:17
  • I would like to solve my python installation no reinstall from scratch – Manicore Oct 14 '21 at 21:27
  • Won't work & good luck. `do-release-upgrade`won't handle your "special" python config. – kanehekili Oct 14 '21 at 21:58
  • Reinstallation costs hours of post-install procedures. @kanehekili Ubuntu is not Windows, Ubuntu can be repaired from any "broken" state using standard tools and knowledge. I'm running do-release-upgrade for years, have a system upgraded from 6.06 LTS to latest 21.10. – N0rbert Oct 15 '21 at 06:39
  • Not sure if this is working only idea from me `sudo dpkg-reconfigure python3` – nobody Oct 15 '21 at 15:37
  • Please show the output of `echo $PATH`. – N0rbert Oct 17 '21 at 11:13

1 Answers1

1

You have to remove your local python from PATH environment variable and run upgrade process by using the following commands:

export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
sudo -E apt-get update
sudo -E apt-get dist-upgrade
sudo -E do-release-upgrade
N0rbert
  • 97,162
  • 34
  • 239
  • 423
  • Thanks, but it asks `Please install all available updates for your release before upgrading.`. What should I do ? – Manicore Oct 16 '21 at 21:12
  • 1
    See update above. – N0rbert Oct 16 '21 at 21:18
  • Now the command `which python` points to `/usr/bin/python` but unfortunnatly the `do-release-upgrade` still complains. `Your python3 install is corrupted. Please fix the '/usr/bin/python3' symlink` – Manicore Oct 17 '21 at 11:08
  • With `python3` pointing to `/usr/bin/python3.9`. Not sure why is the problem – Manicore Oct 17 '21 at 11:10
  • Sure, output is `/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin` – Manicore Oct 17 '21 at 11:23
  • Oh, I finally manage to do it by following this answer, with complete reinstallation of Python 3.7 as suggested in the comment section by @wjandrea https://askubuntu.com/a/1104066/416440 – Manicore Oct 17 '21 at 11:25