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 OverflowThe 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
Videos
How to check the Python version on CMD?
What is a Python version file?
How do I check all my Python versions?
To check the version of one's Python's Software version, one should use the following code in command prompt:
python -V
Reference: http://docs.python.org/using/cmdline.html#generic-options
In a Python IDE, just copy and paste in the following code and run it (the version will come up in the output area):
import sys
print(sys.version)
I just got the answer. By typing "py -h" or "py --help" I got the help message:
C:\Users\admin>py -h
Python Launcher for Windows Version 3.7.1150.1013
usage:
py [launcher-args] [python-args] script [script-args]
Launcher arguments:
-2 : Launch the latest Python 2.x version
-3 : Launch the latest Python 3.x version
-X.Y : Launch the specified Python version
The above all default to 64 bit if a matching 64 bit python is present.
-X.Y-32: Launch the specified 32bit Python version
-X-32 : Launch the latest 32bit Python X version
-X.Y-64: Launch the specified 64bit Python version
-X-64 : Launch the latest 64bit Python X version
-0 --list : List the available pythons
-0p --list-paths : List with paths
Which tells me that "-0" (zero, not letter "O") lists the available pythons:
C:\Users\admin>py -0
Installed Pythons found by py Launcher for Windows
-3.7-64 *
-3.7-32
-2.7-64
-2.7-32
While "-0p" lists not only the versions, but also the paths:
C:\Users\admin>py -0p
Installed Pythons found by py Launcher for Windows
-3.7-64 C:\Users\admin\AppData\Local\Programs\Python\Python37\python.exe *
-3.7-32 C:\Users\admin\AppData\Local\Programs\Python\Python37-32\python.exe
-2.7-64 C:\Python27_64\python.exe
-2.7-32 C:\Python27_32\python.exe
To install a Python version that is not listed there run py install followed by the version number, e.g. py install 3.14
In cmd run:
py --list
My result (all versions of python intalled):
-V:3.11 * Python 3.11 (64-bit)
-V:3.9
-V:3.8 Python 3.8 (64-bit)
-V:3.6 Python 3.6 (64-bit)
-V:3.5
-V:ContinuumAnalytics/Anaconda39-64 Anaconda py39_4.12.0
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?
while installing pyton and vscode on my linuxbox i run a test
well i allway thought that the test of python
[martin@martinsendeavour ~]$ which python /usr/bin/python [martin@martinsendeavour ~]$
well i get back this
[martin@martinsendeavour ~]$ which python
/usr/bin/python [martin@martinsendeavour ~]$
i guess that this is not normal - i have no python on the machine!?
do i
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.