0

I was trying to check the Python version on my device. In the terminal I used the command python --version. But it outputs a message saying

Command 'python' not found, did you mean:

 command 'python3' from deb
 command 'python' from deb python-is-python3

I tried reinstalling Python 3. But it still shows the same thing. What should I do now?

2
  • 2
    python3 --version >> Python 3.8.2. If you like to run python3 using python then install python-is-python3 package. – Ravexina Jul 7 '20 at 8:03
  • 1
    python generally refers to Python 2 unless configured/specified. On releases > 18.04, Python 2 isn't installed by default since it's dead. 20.04 gives you an option to invoke Python 3 using python by merely installing a package. – Kulfy Jul 7 '20 at 8:06
2

Up until Ubuntu 18.04 LTS, both python2 and python3 were preinstalled on Ubuntu. Since Ubuntu 18.04 LTS, things have changed. Python2 is not preinstalled. Only python3 (v3.8.2 in 20.04) is preinstalled. At this moment if you run python3 --version, you will see version 3.8.2 is installed. However if you have also installed python 2 (on your own, it is not preinstalled), then you can use python2 --version or python --version to check the version of python2.

To check info about python3, you will have to use python3 --version or something which starts with python3 explicitly. Where as python and python2 will refer python2.

EDIT 1
The reason they did this was because python2 itself has reached EOL (end of life).
Related news article.

EDIT 2
Python 2 has now been moved to from main repository to universe repository.

The four main repositories are:

Main - Canonical-supported free and open-source software.

Universe - Community-maintained free and open-source software.

Restricted - Proprietary drivers for devices.

Multiverse - Software restricted by copyright or legal issues.

EDIT 3
To make python command to point to python3, install python-is-python3 package by running sudo apt install python-is-python3 command in terminal.

6
  • Python 2 was installed by default until 18.04. – Kulfy Jul 7 '20 at 8:42
  • @Kulfy No, it was first removed in 20.04 LTS. Between 18.04 there were 19.10, 18.10 and 19.04. They had python2 installed in them out of the box. On google also it says that Ubuntu 20.04 was first to drop python2. askubuntu.com/questions/1165360/… in the given question, it was still installed on 19.04. If you still think I am wrong, pls provide me a proof, and I will update my answer. Because to my best knowledge, 20.04 was first to drop python2. – Abhay Patil Jul 7 '20 at 8:56
  • you should add @Ravexina comment to your answer. – bac0n Jul 7 '20 at 9:00
  • @AbhayPatil For proof, see release notes of 18.04. Also, 18.04 was the last LTS release to have Python 2 in main repository. 20.04 has Python 2 in Universe repository. P.S. I'm the owner of the answer on the question you linked. – Kulfy Jul 7 '20 at 9:06
  • 1
    @bac0n pls suggest an edit and I will accept it – Abhay Patil Jul 7 '20 at 9:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.