How do I detect the Python version at runtime? [duplicate]
For example, to check that you are running Python 3.x, use
import sysif sys.version_info < 3: raise Exception("Must be using Python 3")
sys.version_info is the major version number.
sys.version_info would give you the minor version number.
In Python 2.7 and later, the components of
sys.version_info can also be accessed by name, so the major version number is