I recently formatted my laptop and installed the Ubuntu operating system. I did not explicitly install Python. To check if it is pre-installed, I ran python --version in the terminal and got this:
$ python --version
Command 'python' not found, but can be installed with:
sudo apt install python3
sudo apt install python
sudo apt install python-minimal
You also have python3 installed, you can run 'python3' instead.
Then I checked python3 --version and got this: Python 3.6.9.
How is this possible? Should I install python as well? Or can I continue to use python3? Would this cause any problems?
Recent Ubuntu versions do not install python 2 by default, as python 2 is now "dead". However, the command python is not (yet) linked to Python 3, to avoid some confusion; traditionally, python was for python 2 while python3 was for python 3.
In case you want to change this behavior and use python to run python 3, try installing a package named python-is-python3. Then you can run python --version and see that it points to Python 3.
In theory it might cause confusion for some legacy programs, but I haven't seen any issue so far for about a year.
In 20.04 LTS, the
pythonincluded in the base system is Python 3.8. Python 2.7 has been moved to universe and is not included by default in any new installs.Remaining packages in Ubuntu which require Python 2.7 have been updated to use
/usr/bin/python2as their interpreter, and/usr/bin/pythonis not present by default on any new installs. On systems upgraded from previous releases,/usr/bin/pythonwill continue to point topython2for compatibility. Users who require/usr/bin/pythonfor compatibility on newly-installed systems are encouraged to install thepython-is-python3package, for a/usr/bin/pythonpointing topython3instead.— https://wiki.ubuntu.com/FocalFossa/ReleaseNotes
Just python on Linux traditionally refers to Python 2. python3 is the correct command if you want to use Python 3 (which you should, as Python 2 is EOL).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With