how to switch python 2.7 to python 3.7 in ubuntu 19.10

22,158

Solution 1

There is no need to use Anaconda or any other third party packages.

Both Ubuntu 19.04 and Ubuntu 19.10 come with Python 3.7 as default Python version.

You can check this with python3 --version in a terminal.

python will and also should refer to Python 2 - this was decided in order to not brake compatibility. Do not try to change this, or you could break parts of your system.

https://www.python.org/dev/peps/pep-0394/

Solution 2

Just install python 3

sudo apt install python3.7

and you can use python 3 with the command: python3

thats it.

Share:
22,158
political science
Author by

political science

1)https://hackernoon.com/the-decline-of-stack-overflow-7cb69faa575d 2)https://stackoverflow.blog/2019/11/13/were-rewarding-the-question-askers/

Updated on September 18, 2022

Comments

  • political science
    political science over 1 year

    I am using Ubuntu 19.10 and I have python 2.7 installed on it. I want to upgrade to python 3.7 on it. How do I do it? I have downloaded https://www.anaconda.com/ for 3.7 version of Linux and installed it. Does it do the needful or I need to install or upgrade to python 3.7. If I have to do then how should I do it?

    edit this was a Ubuntu 19.04 virtual machine which was upgraded to 19.10 not a clean install. The VMware image for 19.04 was downloaded from www.osboxes.org/ubuntu

     debian@osboxes:~$ python -V
        Python 2.7.17rc1
    
    • steeldriver
      steeldriver over 4 years
      Ubuntu 19.10 should provide python 3.7 out of the box - what does python3 --version say?
    • Alvin Liang
      Alvin Liang over 4 years
      Ubuntu 19.10 installs only python3 and no python 2.7 by default.
    • tripleee
      tripleee over 4 years
      Debian, and thus Ubuntu, takes care to provide the two versions as separate binaries. There is no standard way to get python to refer to a version which is not Python 2 (though of course you are free to set up a personal alias or other local hack as long as you don't wreck the system default)
  • oldfred
    oldfred over 4 years
    And then every application you have that still uses the old python 2.7 and uses python will break. Only specify the version you want in the commands you want or program you write. You are supposed to specify python3 to use python3.
  • Akolade Adesanmi
    Akolade Adesanmi almost 4 years
    Please, I'm unaware of not changing python2 pointer. How can I reset back to original version both python 2 and python 3.7? My Ubuntu version is 19.10
  • Jürgen Gmach
    Jürgen Gmach almost 4 years
    I am afraid, I cannot help you with that.
  • shanavascet
    shanavascet about 3 years
    I was using the wrong command. (python --version). I should have used python3 --version worked for me. I was n't aware. Thanks for the information.