for i in range(2, 4):
    x = Popen('python' + str(i) + ' --version', shell=True, stdout=PIPE,
        stdin=PIPE, stderr=STDOUT)
while x.poll() == None:
    pass
How to list all Python versions installed in the system?