To check the Python version on different operating systems, you can use the command line or terminal. Here’s how to do it on Windows, Mac, and Linux:
- Windows:
- Open the command prompt by pressing
Win + R
, typingcmd
, and hitting Enter. - In the command prompt, type
python --version
orpython -V
and press Enter. - The Python version installed on your Windows system will be displayed.
- Open the command prompt by pressing
- Mac:
- Open the Terminal application. You can find it in the Applications folder under Utilities.
- In the terminal, type
python --version
orpython -V
and press Enter. - The Python version installed on your Mac will be displayed.
- Linux:
- Open the terminal. You can usually find it in the applications menu or use the keyboard shortcut
Ctrl + Alt + T
. - In the terminal, type
python --version
orpython -V
and press Enter. - The Python version installed on your Linux system will be displayed.
- Open the terminal. You can usually find it in the applications menu or use the keyboard shortcut
The command python --version
or python -V
displays the Python version installed as per your system’s PATH environment variable. If you have multiple Python installations, the command will display the version of the default Python interpreter.
Note: If you have both Python 2 and Python 3 installed on your system, you might need to use python3 --version
or python3 -V
to check the version of Python 3 specifically.
Alternatively, you can run a Python script to check the version. Create a new text file, enter the following line, and save it with a .py
extension (e.g., version_check.py
):
import sys
print(sys.version)
Then, open the command prompt or terminal, navigate to the directory containing the script, and run python version_check.py
to see the Python version.
These methods should help you determine the Python version installed on your Windows, Mac, or Linux system.