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
You can use the platform module which is part of the standard Python library:
$ python -c 'import platform; print(platform.python_version())'
2.6.9
This module allows you to print only a part of the version string:
$ python -c 'import platform; major, minor, patch = platform.python_version_tuple(); print(major); print(minor); print(patch)'
2
6
9