To check the Python version in your shell, you can use the following alternatives (aliases):
Terminal: The following commands can be used to check the Python version in your terminal. Note that the first and second are aliases whereas the third one provides more information about the built.
python --version
python -V
python -VV

Note that you can also use the short-hand py
command to check the Python version in your terminal:
py --version
py -V
py -VV
To learn about the difference between “py
” and “python
” commands, check out this article on the Finxter blog.
Script: You can also check the Python version in your Python script.
You can import the sys
library and call the sys.version
attribute to obtain a string representation of your Python version.:
import sys print(sys.version) # 3.9.5 (tags/v3.9.5:0a7dcbd, May 3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)]
Even simpler, you can also just check the IDLE code editor for basic version information:

You can also obtain the version info in a tuple by using the following alternative:
import sys print(sys.version_info) # sys.version_info(major=3, minor=9, micro=5, releaselevel='final', serial=0)
An alternative is to use the following platform.python_version()
method:
import platform print(platform.python_version()) # 3.9.5
And if you need the version info in a tuple, use the following alternative:
import platform print(platform.python_version_tuple()) # ('3', '9', '5')
You can learn more about checking your Python version on the in-depth Finxter tutorial.