← Go Back

How to Check the Python Version

Using the platform standard module:

>>> import platform
>>> platform.python_version()
'3.12.0'

To get the three numbers separately (known as major, minor, and build) use:

>>> platform.python_version_tuple()
('3', '12', '0')

The module can also determine what the Python implementation is (CPython, Jython, IronPython, etc.):

>>> platform.python_implementation()
'CPython'

Other information related to the Python interpreter:

>>> platform.python_build()
('tags/v3.12.0:0fb18b0', 'Oct 2 2023 13:03:39')
>>> platform.python_compiler()
'MSC v.1935 64 bit (AMD64)'
>>> platform.python_branch()
'tags/v3.12.0'
>>> platform.python_revision()
'0fb18b0'


platform


🐍 You might also find interesting: