5

I have installed python 3.10 on my Ubuntu. Now I have there two versions: 3.8 and 3.10. I would like to set Python 3.10 as a default. I followed the advice here: Change the Python3 default version in Ubuntu

ls /usr/bin/python*
/usr/bin/python3     /usr/bin/python3.8-config  /usr/bin/python3-pasteurize
/usr/bin/python3.10  /usr/bin/python3-config
/usr/bin/python3.8   /usr/bin/python3-futurize

I tried to set get python3.10 priority 1 and python3.8 priority 2:

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 2
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1

I can check it using:

sudo update-alternatives --config python
There are 2 choices for the alternative python (providing /usr/bin/python).

Selection Path Priority Status

0 /usr/bin/python3.8 2 auto mode

  • 1 /usr/bin/python3.10 1 manual mode 2 /usr/bin/python3.8 2 manual mode

But when I check current python version I still see the old one:

python3 --version
Python 3.8.10

How can I fix my problem please?

vojtam
  • 151
  • @schrodigerscatcuriosity yes, it shows python 3.10. But why it does not work for python3 --version ? – vojtam Jan 26 '22 at 09:48
  • 1
    Oh, I was right then. I think it's because in your command you used /usr/bin/python python instead of /usr/bin/python3 python3. – schrodingerscatcuriosity Jan 26 '22 at 09:49
  • 3
    Do not change the default version. You can run as many versions of python as you want, just have to specify in your programs. But Ubuntu depends and uses the default version. You will potentially break system. In older systems, reinstall was only option, now chroot & repair may work, but you best have good backups so you can reinstall. – oldfred Jan 26 '22 at 14:48
  • @oldfred Pedantics aside how can the python/python3 in a given session be pointed to the 3.10 ? – WestCoastProjects Mar 16 '23 at 15:35
  • @WestCoastProjects You just specify as posted above, just not python3, but python3.10 assuming you installed it so /usr/bin is correct. whereis python3 Many suggest Many suggest this: https://github.com/pyenv/pyenv pyenv lets you easily switch between multiple versions of Python. But I have always use default and if necessary update the few programs of mine that use python. – oldfred Mar 16 '23 at 19:26

0 Answers0