Finding your Python version from the command line
The fastest way to find your Python version is to open a terminal or command prompt and run a single command. On Windows, press the Windows key, type cmd, and press Enter. On Mac or Linux, open Terminal from your Applications folder or press Ctrl+Alt+T.
Once the terminal is open, type this exactly: python --version and press Enter. Python will print the version number on the next line. If that doesn't work, try python3 --version instead — many systems have both Python 2 and Python 3 installed, and the second command specifically checks for Python 3.
If neither command works, Python may not be installed on your system, or it may not be in your system's PATH (the list of places your computer looks for programs). This is common on Windows, especially if you installed Python but didn't check the "Add Python to PATH" box during setup.
Key Takeaways
- Open a terminal or command prompt and type python --version or python3 --version to see your version number immediately.
- If the command doesn't work, Python may not be installed or may not be in your system's PATH — you may need to reinstall it.
- On Windows, you can also check the version by opening Python directly and looking at the first line of text that appears.
- If you have both Python 2 and Python 3, use python3 --version to check the version you're most likely to use.
Checking Python version on Windows without a terminal
If you're uncomfortable with the command line, you can open Python directly. Click the Windows Start button, type python, and click the Python application when it appears. A window will open with text at the top showing your version number — it looks something like "Python 3.11.5 (main, Sep 2 2024, 16:31:13)". The three numbers at the start (3.11.5 in this example) are what you need.
Close this window by typing exit() and pressing Enter, or by clicking the X button. This method works only if Python is installed and accessible from your Start menu, which means it was added to your PATH during installation.
Finding Python version inside a script or IDE
If you're already writing Python code, you can check the version from within your script. Add this line to your code: import sys; print(sys.version). When you run the script, it will print the full version information, including the release date and compiler details.
If you use an IDE like Visual Studio Code, PyCharm, or IDLE (which comes with Python), you can often see the version in the settings or status bar. In VS Code, look at the bottom right corner — it usually shows which Python interpreter is active. In PyCharm, go to File > Settings > Project > Python Interpreter and look at the dropdown menu.
What to do if Python isn't found
If you run python --version and get an error like "python is not recognized" or "command not found", Python either isn't installed or isn't in your system's PATH. The fastest fix on Windows is to reinstall Python from python.org. During installation, check the box that says "Add Python to PATH" before clicking Install.
On Mac, Python 2 comes built in, but Python 3 usually doesn't. If you need Python 3, install it from python.org or use a package manager like Homebrew. On Linux, use your package manager: sudo apt install python3 on Ubuntu or Debian, or sudo yum install python3 on Red Hat or CentOS.
After reinstalling or installing Python, close and reopen your terminal completely before trying the python --version command again. The terminal needs to refresh its list of available programs.
Understanding version numbers
Python version numbers follow a pattern: major.minor.patch. A version like 3.11.5 means major version 3, minor version 11, and patch version 5. The major version (3 vs. 2) is the biggest difference — Python 2 and Python 3 are not compatible with each other, and Python 2 stopped being updated in 2020. Almost all new code uses Python 3.
The minor version (the middle number) adds new features but keeps old code working. The patch version (the last number) fixes bugs without adding features. For most purposes, knowing your major and minor version is enough — knowing you have Python 3.11 tells you what features are available, while the patch number (5) is less important for everyday use.
Checking which Python your system uses by default
On many systems, typing python runs Python 2, while python3 runs Python 3. You can check which version each command points to by running both: python --version and python3 --version. This matters if you're running code from a script or another program, because the system may default to Python 2 unless you specifically ask for Python 3.
If you want to change the default, you can create an alias in your terminal settings, but this is usually unnecessary. Instead, when you need Python 3, just use the python3 command explicitly. If you're writing a script that others will run, add a shebang line at the very top: #!/usr/bin/env python3. This tells the system to use Python 3 no matter what the default is.
Frequently Asked Questions
Why do I have both python and python3 commands?
Many systems have Python 2 and Python 3 installed side by side. Python 2 is older and no longer updated, but some older programs still need it. Python 3 is the current version. Using python3 ensures you're using the modern version, while python may point to either one depending on your system.
Does the patch version (the last number) matter?
Patch versions fix security bugs and small problems, so newer is safer. However, code written for Python 3.11.0 will run fine on Python 3.11.5. The major and minor versions matter much more — code written for Python 3 won't run on Python 2, and some features only exist in newer minor versions.
What if I have multiple Python versions installed?
You can check each one separately: python --version, python3 --version, python3.9 --version, and so on. To see the full path to each installation, use which python3 on Mac or Linux, or where python on Windows. This helps you understand which version runs when you type a command.
Can I update Python from the command line?
On Linux, yes — use your package manager like sudo apt upgrade python3. On Windows and Mac, download the new version from python.org and run the installer. The installer will update your existing installation or install a new version alongside the old one, depending on your choices during setup.