Score:1

Unable to do-release-upgrade because which python point to env/bin/python

gb flag

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
kanehekili avatar
zw flag
I'd tried that once. My advice: don't do it. Save your data and install it freshly...
Manicore avatar
gb flag
Do you suggest to reinstall from scratch ? but why ?
Nmath avatar
ng flag
Because your python installation is corrupted
kanehekili avatar
zw flag
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.
Manicore avatar
gb flag
I would like to solve my python installation no reinstall from scratch
kanehekili avatar
zw flag
Won't work & good luck. `do-release-upgrade`won't handle your "special" python config.
N0rbert avatar
zw flag
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.
nobody avatar
gh flag
Not sure if this is working only idea from me `sudo dpkg-reconfigure python3`
N0rbert avatar
zw flag
Please show the output of `echo $PATH`.
Score:1
zw flag

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
Manicore avatar
gb flag
Thanks, but it asks `Please install all available updates for your release before upgrading.`. What should I do ?
N0rbert avatar
zw flag
See update above.
Manicore avatar
gb flag
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 avatar
gb flag
With `python3` pointing to `/usr/bin/python3.9`. Not sure why is the problem
Manicore avatar
gb flag
Sure, output is `/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin`
Manicore avatar
gb flag
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
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.