I\'d like to detect if python is installed on a Linux system and if it is, which python version is installed.
How can I do it? Is there something more graceful than
Detection of python version 2+ or 3+ in a shell script:
# !/bin/bash ver=$(python -c"import sys; print(sys.version_info.major)") if [ $ver -eq 2 ]; then echo "python version 2" elif [ $ver -eq 3 ]; then echo "python version 3" else echo "Unknown python version: $ver" fi