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 -Vand 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.
While working as a researcher in distributed systems, Dr. Christian Mayer found his love for teaching computer science students.
To help students reach higher levels of Python success, he founded the programming education website Finxter.com. He’s author of the popular programming book Python One-Liners (NoStarch 2020), coauthor of the Coffee Break Python series of self-published books, computer science enthusiast, freelancer, and owner of one of the top 10 largest Python blogs worldwide.
His passions are writing, reading, and coding. But his greatest passion is to serve aspiring coders through Finxter and help them to boost their skills. You can join his free email academy here.