I would like to know the version of Python that I am using to run some code in my Linux environment. Over time I have several versions installed and so I just want to check the version that runs my simple code when I run code from the terminal like:
$ ./<filename>.py
When I try the following, I get different conflicting answers
[user@localhost bin]$ /usr/bin/python -V
Python 2.7.15
[user@localhost bin]$ /usr/bin/python3 -V
Python 3.6.6
[user@localhost bin]$ python -V
Python 2.7.15
How can I find out which version is active?
#!/usr/bin/pythonand set executablechmod +x script.pyand Linux will use python from shebang to run this script.sys.versionorsys.version_info