3

I've just now installed Python 3.7 and I'd like to understand why I get the following output from bash:

g-luca@hp-notebook:~$ python3.7 -V
Python 3.7.0
g-luca@hp-notebook:~$ python3 -V
Python 3.5.2
g-luca@hp-notebook:~$ python -V
Python 2.7.12
wjandrea
  • 14,236
  • 4
  • 48
  • 98
glc78
  • 481

1 Answers1

2

You need to check which symlinks are in place. The Python binaries are located in the directory /usr/bin (check with which pythonX.Y). The python3 symlink points to the python3.5 binary.

As mentioned in the comments: if you don't want to type python3.7 every time you shouldn't change the symlink. Changing the Python version might brake system stuff in unexpected ways. You should rather create an alias in your shell. In Bash you would add something like alias python=python3.7 into ~/.bashrc.

Sethos II
  • 541
  • 2
    You should mention that, changing that python3 symlink is generally a bad idea. because it can break the whole system if you do. same with the python symlink. – Videonauth Sep 28 '18 at 08:27
  • I've Python2, 2.7, 3 and 3.5 at /usr/bin and Python3.7 at /usr/local/bin. which python says /usr/bin that is why Python3.7 is not the default one. The reason why starts Python2.7 instead of Pyhton3.5 installed in same folder, should reside in the symlinks, am I right? – glc78 Sep 29 '18 at 14:14
  • @glc78 Yes, /usr/bin/python is a symlink to /usr/bin/python2.7, therefore this is the default. – Sethos II Sep 30 '18 at 09:34
  • @SethosII And I leave it as it is, just made an alias for python3.7 command. A question: are the old versions of Python required for backward compatibility? – glc78 Sep 30 '18 at 13:32
  • 1
    @glc78 The versions from the ubuntu repository are the ones used for testing the python software in the repositories. So it isn't about backward compatibility but stability. – Sethos II Oct 01 '18 at 05:08
  • @SethosII Ok, good to know, but maybe I did not wrote what I have in mind. For compatibilty I mean if could an old python code need an old python versions to work correctly. – glc78 Oct 01 '18 at 21:55