I have different python versions installed (from source) on my server. Now I'd like to be able to get the version of a python executable from another python script (running another python version).
I know I can do it from the shell with path/to/python -V
. But I'd like to do it from a script, like:
command = ' '.join([pythonpath, '-V'])
output = subprocess.check_output( command, shell=True )
print output
But in this case check_output does not work as expected: the output is shown in the terminal but does not go into the variable output.