To check your Python 3 version, open a terminal or command prompt and run python3 --version (Linux/macOS) or python --version (Windows). You’ll see output like Python 3.12.4; if that fails, try python3 -V or py --version. This article explains every reliable method, how to read the version string, and what to do when commands don’t work.
Why the Version Matters
Python 3 has been under active development since 2008, and each minor release adds features, optimizations, and breaking changes. For example, f-strings were introduced in 3.6, the walrus operator (:=) in 3.8, and pattern matching in 3.10. Code written for 3.9 may not run on 3.7, and some libraries drop support for older versions. Knowing your exact version helps you:
- Install compatible packages with pip
- Debug cryptic syntax errors
- Decide whether to upgrade your environment
- Follow tutorials that specify a minimum version
Most modern Linux distributions and macOS ship with Python 3 pre-installed, but the version varies widely—from 3.8 on older Ubuntu to 3.12 on recent Fedora. Windows doesn’t include Python by default, so you may have multiple installations from different sources.
The Basic Commands
The most direct way is the --version flag. Open your terminal (Linux/macOS) or Command Prompt/PowerShell (Windows) and type one of these:
python3 --version— the standard on Linux/macOSpython --version— often works on Windows and some Linux setupspy --version— the Windows launcher, which manages multiple Python installspython3 -V— a shorter alias for--version
Each prints a single line to standard output. For example, python3 --version might return Python 3.11.8. If you get Python 2.7.x from python --version, that’s Python 2, which is end-of-life since 2020—use python3 instead.
Using the Interactive Shell
If you’re already inside the Python interpreter, you can check the version without leaving it. Start the shell by typing python3 (or python on Windows), then run:
import sys print(sys.version)
This prints a longer string like 3.11.8 (main, Feb 7 2024, 21:52:08) [GCC 13.2.0]—it includes the build date and compiler info. For just the version number, use:
import sys print(sys.version_info)
That outputs a tuple like sys.version_info(major=3, minor=11, micro=8, releaselevel='final', serial=0). You can also access individual fields, e.g., sys.version_info.major gives 3. This method is useful when writing code that must behave differently on different versions.
Checking Within a Script
To verify the Python version programmatically, add these lines to any script:
import platform print(platform.python_version())
This returns just 3.11.8—no extra text. The platform module is part of the standard library, so it works everywhere. Another approach:
import sys
print(f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}")
Both are handy for scripts that need to log the environment or check a minimum version before running. For example, you might do:
if sys.version_info < (3, 8):
raise SystemExit("Python 3.8 or newer is required")
What to Do When Commands Fail
Sometimes python3 --version returns nothing or an error. Common causes and fixes:
- Command not found — Python isn’t installed or not in your PATH. On Windows, install from python.org or the Microsoft Store. On Linux, use your package manager (e.g.,
sudo apt install python3). - Multiple versions — You might have 3.8 and 3.12 installed. Use
python3.12 --versionto target a specific one, or checkwhich python3to see which binary is first in PATH. - Aliases — Some systems alias
pythonto Python 2. Usepython3explicitly, or checkaliasin your shell. - Windows Store stub — On Windows, typing
pythonmay open the Microsoft Store. Disable the app execution alias in Settings > Apps > Advanced app settings > App execution aliases.
If you need to know where Python is installed, run which python3 (Linux/macOS) or where python (Windows). That shows the full path, which helps when you have multiple installations.
Comparing Python 2 vs Python 3
You might see Python 2.7.18 if you run python --version on an older system. Python 2 reached end-of-life in January 2020 and receives no security updates. Most modern code and libraries are Python 3-only. If you’re maintaining legacy code, you’ll need both versions installed, but for any new project, use Python 3. To avoid confusion, always use python3 on systems that still have Python 2 in PATH.
Using the Windows Py Launcher
Windows users have a special tool called the Python Launcher, invoked as py. It’s installed alongside Python from python.org. The command py --version shows the default version, and py -0 lists all installed Python versions. To run a specific one, use py -3.11 or py -3.12. This is the most reliable way to manage multiple Python installs on Windows, especially when the python command is ambiguous.
Frequently Asked Questions
What’s the difference between python --version and python3 --version?
On many systems, python points to Python 2 (or nothing), while python3 points to Python 3. On Windows, python usually refers to Python 3 if installed from python.org. The safest bet is to try both and see which gives a Python 3.x version.
How do I check the Python version in a Jupyter notebook?
Run a cell with import sys; print(sys.version). That prints the full version string. You can also use !python --version in a cell to run the shell command.
Why does python3 --version show nothing on Windows?
Windows often uses python instead of python3. If python --version also fails, Python may not be in PATH, or the Microsoft Store alias is interfering. Use py --version instead, or reinstall Python and check “Add Python to PATH” during setup.
Can I check the version without a terminal?
Yes. In an IDE like PyCharm or VS Code, look at the interpreter settings—it shows the path and version. You can also run a Python script from any editor that prints sys.version.
What does sys.version_info return?
It returns a named tuple with fields major, minor, micro, releaselevel, and serial. For Python 3.11.8, it’s sys.version_info(major=3, minor=11, micro=8, releaselevel='final', serial=0).
How do I check if my Python is 64-bit or 32-bit?
Run import platform; print(platform.architecture()). It returns something like ('64bit', 'WindowsPE'). This matters for installing certain binary packages.
Related
General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.
More in this bed
- iOS 18 Safari Not Working? Fixes That Help
- How to Check Your Linux Kernel for Spectre
- iPhone Safe Mode: How to Enable or Disable It
- Fix Slow Internet Lag on Samsung Galaxy Note
- How to Get iOS 17 on iPhone X (Safe Methods)
- Fix Gmail IMAP Error in Outlook: Step-by-Step