
Let's say the python --version command returns version 2 of Python.
~]# python --version
Python 2.7.5
And the python3 command returns version 3 of Python.
~]# python3 --version
Python 3.6.8
This is because the python command is most likely symbolically linked to version 2 of Python and the python3 comand is most likely symbolically linked to version 3 of Python.
]# ll /usr/bin/ | grep -i python
lrwxrwxrwx. 1 root root 7 Jul 9 02:24 python -> python2
lrwxrwxrwx. 1 root root 9 Jul 9 02:24 python3 -> python3.6
You do not want to change the python symbolic link to point to python3 because some commands, such as yum, expect version 2 of Python.
The alias command can be used to temporarily update the python command to run python3 for a specific user. For example, for only user john.doe, the following command could be issued so that the python command runs python3. It's important to recongize that once john.doe disconnects his SSH session, the alias would no longer be set for john.doe.
alias python=python3
export alias
Did you find this article helpful?
If so, consider buying me a coffee over at