How to Check Which Python Version Is Installed
Find out which Python version is installed and which interpreter actually runs when you type python or python3, on Mac, Linux, and Windows.
Before installing a package or running someone else's script you need to know which Python you have. One command tells you, but the command name differs by system.
Ask python3 for its version
python3 --version
Python 3.12.4
This is the command to use on macOS and Linux, where python3 is the standard name for the Python 3 interpreter.
Try python if python3 is not found
python --version
On Windows the installer registers the interpreter as python, so this is the normal command there. On Mac and Linux, python may not exist at all, or it may point to a different install than python3. Both commands can exist on one machine and report different versions, which is why you should check the one you actually plan to run.
Find where the interpreter lives
which python3
/usr/bin/python3
On Windows, use where python instead. The path tells you whether the interpreter came with the OS, from python.org, from Homebrew, or from a virtual environment. If a virtual environment is active, the path points inside its folder.
Print the full version details
python3 -c "import sys; print(sys.version)"
The output includes the patch version, build date, and compiler, which is useful when reporting a bug or checking whether a build is 64-bit. Inside a script, sys.version_info gives a tuple you can compare directly, for example sys.version_info >= (3, 12).
On Windows with several versions installed. The py launcher that ships with the python.org installer lists every install it knows about with py -0. Run a specific one with py -3.12 --version. This is the quickest way to see whether an older version is shadowing the one you expect.
If the reported version is older than expected. A newer Python may be installed but later in your PATH. Compare which -a python3 on Mac or Linux, which prints every match in PATH order, and use the full path or a virtual environment to pick the right one.
More Coding how-tos
- How to Add a .gitignore File
- How to Check Which Node.js Version Is Installed
- How to Clone a Git Repository
- How to Create a New Git Branch
- How to Create a Python Virtual Environment
- How to Install Node.js with nvm
- How to Make a Script Executable in the Terminal
- How to Print Hello World in JavaScript
- How to Print Hello World in Python
- How to Run a Local Web Server in One Command
- How to Undo the Last Git Commit