To check the default Python version on your macOS, use the command python --version
in your terminal.
$ python --version Python 3.9.5
In particular, use the following four steps to check the Python version on your Mac operating system.
- Press CMD + Space to open Spotlight.
- Type βterminalβ and press enter.
- Execute command: type
python --version
orpython -V
and press enter. - The Python version appears in the next line below your command.
However, this may not give you the whole truth—if you’re like me, you’ve installed multiple versions over the years. Which ones? Well the question gives the answer:
To check all versions on your macOS, open the terminal and run "which -a python"
.
The “which” command locates a program file location.
Syntax which [-as] program ... Flag -a List all found executables, not just the first -s Return 0 if any of the executables are found and 1 otherwise
If you run the specified program(s), the macOS performs some intermediate steps to resolve the command such as substitutions or searching the path of the command. The “which
” command displays the path of the resolved program after those operations.