Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I don't have python but I have python3 [duplicate]

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?

like image 776
Shabnam Avatar asked Feb 18 '26 15:02

Shabnam


2 Answers

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 python included 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/python2 as their interpreter, and /usr/bin/python is not present by default on any new installs. On systems upgraded from previous releases, /usr/bin/python will continue to point to python2 for compatibility. Users who require /usr/bin/python for compatibility on newly-installed systems are encouraged to install the python-is-python3 package, for a /usr/bin/python pointing to python3 instead.

— https://wiki.ubuntu.com/FocalFossa/ReleaseNotes

like image 181
j1-lee Avatar answered Feb 20 '26 05:02

j1-lee


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).

like image 41
SuperStormer Avatar answered Feb 20 '26 06:02

SuperStormer