How to check the Python version in Ubuntu?

To check the Python version on Ubuntu, you can use one of the following methods:

Run the command `python –version` in the terminal.

$ python --version

This will display the installed version of Python.

Run the command `python3 –version` in the terminal.

$ python3 --version

This will display the version number of Python 3.

Open the terminal and start the Python interpreter.

$ python

Next, enter the following code in the Python interactive environment to get the Python version:

import sys

print(sys.version)

This will display the full information of the Python version, including the version number and other details.

Please note that depending on the version of Python installed on your system, you may need to use the command `python3` instead of `python` to access Python 3.

bannerAds