The more easy way its by executing the next command:
ls -ls /usr/bin/python*
Output look like this:
/usr/bin/python /usr/bin/python2.7 /usr/bin/pythonw
/usr/bin/python-config /usr/bin/python2.7-config /usr/bin/pythonw2.7
Answer from Gabriel Caceres on Stack OverflowVideos
The more easy way its by executing the next command:
ls -ls /usr/bin/python*
Output look like this:
/usr/bin/python /usr/bin/python2.7 /usr/bin/pythonw
/usr/bin/python-config /usr/bin/python2.7-config /usr/bin/pythonw2.7
we can directly use this to see all the pythons installed both by current user and the root by the following:
whereis python
You can use python -V (et al.) to show you the version of Python that the python command resolves to. If that's all you need, you're done. But to see every version of python in your system takes a bit more.
In Ubuntu we can check the resolution with 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:
$ readlink -f $(which python) | xargs -I % sh -c 'echo -n "%: "; % -V'
/usr/bin/python2.7: Python 2.7.6
But this is still only telling us what our current 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
This is real output.
The fact is there could be hundreds of different versions of Python secreted around your system, either on paths that are contextually added, or living under different binary names (like python3).
If we assume that a Python binary is always going to be called python<something> and be a binary file, we can just search the entire system for files that match those criteria:
$ sudo find / -type f -executable -iname 'python*' -exec file -i '{}' \; | awk -F: '/x-executable; charset=binary/ {print $1}' | xargs readlink -f | sort -u | xargs -I % sh -c 'echo -n "%: "; % -V'
/home/oli/venv/bin/python: Python 2.7.4
/media/ned/websites/venvold/bin/python: Python 2.7.4
/srv/chroot/precise_i386/usr/bin/python2.7: Python 2.7.3
/srv/chroot/trusty_i386/usr/bin/python2.7: Python 2.7.6
/srv/chroot/trusty_i386/usr/bin/python3.4: Python 3.4.0
/srv/chroot/trusty_i386/usr/bin/python3.4m: Python 3.4.0
/usr/bin/python2.7: Python 2.7.6
/usr/bin/python2.7-dbg: Python 2.7.6
/usr/bin/python3.4: Python 3.4.0
/usr/bin/python3.4dm: Python 3.4.0
/usr/bin/python3.4m: Python 3.4.0
/web/venvold/bin/python: Python 2.7.4
It's obviously a pretty hideous command but this is again real output and it seems to have done a fairly thorough job.
Type following in the terminal (Ctrl+Alt+T):
python -V
or
python --version
You can find a list of options/parameters for many commands in the terminal by typing the command followed by --help
Example:
python --help
Manual/manpages also available for most of such CLI which can be displayed by man <command> (Ex: man python)
From man python:
COMMAND LINE OPTIONS
-V , --version
Prints the Python version number of the executable and exits.
There is also python3 installed on many machines, so you can do:
python3 --version
to find out what python 3.x you are running.
I've coded a bit in Python for years, and had an existing installation of 3.10.7 which I installed using Chocolatey some time ago.
Then I thought I would play with WhisperX. The tutorial I found walked me through installing Anaconda, which I did not realize would install a second copy of Python, this time 3.12. It broke a couple of existing projects, and so I gave up on WhisperX and swapped the PATH variable back to the 3.10 installation.
Then, last week, I read about Gemma3 and thought I might experiment with that. I found a blog post -- can you see where this is going? -- that pointed me to Ollama. Which I installed, once again not realizing it would install yet another copy of Python, this time 3.13. It didn't break my projects this time, but I think that's because the user-level PATH variable is still pointing at 3.10 while the system-level PATH variable is pointing at 3.13. Oh, and I never got Gemma3 up and running, possibly because it doesn't like 3.10.
So now I have three copies of Python installed, they're fighting with one another over the PATH variable, and I still haven't gotten to experiment with local AI stuff. There's got to be a better way to manage these things.
My googling so far has pointed me at pyenv, which as far as I can tell is a Linux-only utility. I think. I love me some Linux, but the machine in question is a Windows box. Is there some obvious utility I should be using for swapping back and forth between versions that I'm just not finding?