3

I am not very experienced at Linux but I recently installed Ubuntu 19.10 and I am trying to use Python 3 and the default is Python 2. I spent a lot of time reading how to configure Ubuntu to run Python 3 but I felt to do it. Can anyone please help me? I used these commands but nothing works...

sudo update-alternatives --list python
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7
Eliah Kagan
  • 117,780
  • 4
    Don't do change default python. It will break many things. – Pilot6 Nov 15 '19 at 19:53
  • 1
    https://wiki.ubuntu.com/Python explains Python 3 is the default, not 2.7. – K7AAY Nov 15 '19 at 19:55
  • 4
    Might be a classic confusion: python always refers to Python2 (in accordance with PEP394). Don't change that behavior in Ubuntu, or you will break things. However, python (py2) is NOT installed by default in newer releases of Ubuntu anymore anyway. Instead, python3 is installed, and important parts of your system (like apt) rely upon it. Don't change it either. – user535733 Nov 15 '19 at 20:25

1 Answers1

1

Changing the default Python interpreter is probably no good idea, as system tools could depend on the Python version.

As Python 2 support officially ends at the beginning of 2020, it is certainly a good idea to use Python 3 when you create new projects.

In order to use Python 3, just enter python3 in the terminal.

There is no need to change the default behavior.

Jürgen Gmach
  • 695
  • 5
  • 12
  • Their must more problem than python 3 issues with ubuntu-19.10 because now the terminal is not responding and I restarted my PC ... – user1016220 Nov 15 '19 at 20:35
  • Assuming all OP wants is to point the command python to python3, wouldn't modifying .bashrc suffice? My understanding is that .bashrc is only executed in interactive shells, not scripts and such. – Jack M Nov 15 '19 at 20:48
  • 1
    @user1016220 You mentioned terminals not starting; your text terminals (ctrl+alt+f4 etc) should work normally (they don't use python), however some GUI terminals do use python so if you change default behavior in regards python - some GUI terminals may no longer start. That's why you got breakage warnings. You'll just need to use text terminals to undo whatever you did. – guiverc Nov 15 '19 at 21:07