How to check the version of Python on your system in several ways
Published on Aug. 22, 2023, 12:15 p.m.
You can check the version of Python on your system in several ways. Here are a few methods:
- Using the command line: Open your command prompt or terminal and type
python --version
. This will output the current version of Python that is installed on your system. - Using the
platform
module: You can import theplatform
module in Python and use itspython_version()
function to retrieve the Python version on your system. Here’s an example:
import platform
print(platform.python_version())
- In Python console, you can also use the
sys
module to obtain the version information about your Python installation, like this:
import sys
print(sys.version)
Whichever method you choose, you should get a string that contains the version of Python that is currently installed.