python -V shows the version of Python that the python command resolves to.This one is one easy way to figure out python version you are currrently using, but there are other uniwue methods to know which Python version you are using through terminal. Type python in terminal & by default you will see this below:
Here Python 2.7.6 is the version of your python.Python 2.7.6 (default, Mar 22 2014, 22:59:56) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>
In case you tpye python 3.4 you will see:
In Ubuntu we can check the resolution withPython 3.4.1 (default, Jul 31 2014, 12:46:17) [GCC 4.8.2] on linux Type "help", "copyright", "credits" or "license" for more information. >>>
readlink -f $(which python)
. In default cases in 14.04 this will simply point to /usr/bin/python2.7
.We can chain this in to show the version of that version of Python:
But this is still only telling us what our current$ readlink -f $(which python) | xargs -I % sh -c 'echo -n "%: "; % -V' /usr/bin/python2.7: Python 2.7.6
python
resolution is. If we were in a Virtualenv (a common Python stack management system) python
might resolve to a different version:$ readlink -f $(which python) | xargs -I % sh -c 'echo -n "%: "; % -V' /home/oli/venv/bin/python: Python 2.7.4