Printing Python version in output


Question

How can I print the version number of the current Python installation from my script?

1
410
6/4/2019 11:28:26 AM

Try

import sys
print(sys.version)

This prints the full version information string. If you only want the python version number, then Bastien LĂ©onard's solution is the best. You might want to examine the full string and see if you need it or portions of it.

504
5/23/2017 11:54:59 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon