check version of python in ubuntu code example
Example 1: how to check python version
# To check your Python version in the command line use:
python --version
# To check your Python verson inside a script use:
import sys
print(sys.version)
Example 2: check all python versions ubuntu
# View as version vise:
for p in $(compgen -c python); do printf "%-16s" $p; $p --version; done
python2.7 Python 2.7.6
python3.4m Python 3.4.3
# view as:
$ compgen -c python
python2.7
python3.4m
Example 3: check python version ubuntu
python3 --version