How to Find Your Python Version (All Methods Explained)
Knowing which version of Python you're running isn't just a housekeeping detail — it directly affects which libraries you can install, whether your code will run, and how you troubleshoot errors. Python 2 and Python 3 behave differently enough that version mismatches cause real problems, and even within Python 3, minor version differences matter for certain features and packages.
Why Your Python Version Matters
Python has gone through significant changes over the years. Python 2 reached end-of-life in January 2020, meaning it no longer receives security updates. Python 3 is now the standard, but it's not a single fixed target — Python 3.8, 3.10, and 3.12 each introduced features, deprecated old ones, and changed how certain things behave under the hood.
When you install a library like NumPy, TensorFlow, or Django, the package maintainers specify which Python versions they support. Installing a package incompatible with your Python version is one of the most common sources of "it won't install" errors. Knowing your exact version — including the major, minor, and patch numbers — is step one in diagnosing those issues.
How to Check Your Python Version from the Command Line 💻
This is the fastest and most reliable method on any operating system.
On Windows (Command Prompt or PowerShell):
python --version or
python -V On macOS or Linux (Terminal):
python3 --version The output looks like: Python 3.11.4
That string breaks down as:
- 3 = major version
- 11 = minor version
- 4 = patch/micro version
Important: On many macOS and Linux systems, typing
python(without the3) still points to Python 2, whilepython3points to Python 3. Both may be installed simultaneously. Always check both if you're unsure which is being used by your scripts or tools.
Checking Which Python a Script Is Actually Using
Running python --version tells you what the terminal defaults to, but that isn't always the version your scripts or virtual environments are using.
Inside a Python script or interactive session:
import sys print(sys.version) This outputs the full version string, including build details — something like: 3.11.4 (main, Jul 5 2023, 09:00:00)
For a cleaner, programmatic result:
import sys print(sys.version_info) Output: sys.version_info(major=3, minor=11, micro=4, releaselevel='final', serial=0)
This is especially useful when you want to add version-checking logic inside your own scripts — for example, raising an error if someone tries to run your code on an unsupported version.
Checking Python Version Inside a Virtual Environment
Virtual environments are isolated Python installations that let you keep project dependencies separate. If you're using venv, conda, pipenv, or pyenv, the active Python version may differ from your system default.
To check:
- Activate the virtual environment first
- Then run
python --versionorpython3 --version
The version shown will be the one tied to that environment — not necessarily your system Python.
| Environment Tool | How to Check Active Version |
|---|---|
venv | Activate it, then python --version |
conda | conda activate myenv, then python --version |
pyenv | pyenv version or python --version after switching |
pipenv | pipenv run python --version |
Checking Python Version on Windows Without a Terminal 🪟
If you've installed Python through the Microsoft Store or the official Python installer, you can check the version through:
- Settings → Apps → Installed Apps — search for "Python"
- The Python Launcher for Windows (
py --version) if it was installed alongside Python
The Python Launcher (py) is a Windows-only tool that manages multiple Python versions. Running py -0 lists all installed versions on your machine, which is useful if you've installed Python 2 and 3 side by side.
When the Version Number Isn't Enough
Knowing the version number solves most problems, but a few situations require more context:
- 32-bit vs 64-bit builds: Some packages only support one or the other. You can check with
python -c "import struct; print(struct.calcsize('P') * 8)"— it outputs32or64. - CPython vs alternatives: Most users run CPython (the standard reference implementation), but Jython, PyPy, and MicroPython all identify differently when queried. The
sys.versionstring includes implementation details. - System Python vs user-installed Python: On Linux especially, the system may use a Python installation for internal tools that you shouldn't modify. User-installed versions via
pyenvordeadsnakesPPA run separately.
What Affects Which Python Version You Have
The version you find depends on several overlapping factors:
- Operating system: macOS ships with Python 3 pre-installed (since Monterey), some Linux distros still default to older 3.x releases, and Windows requires manual installation
- Installation method: Official python.org installer, Microsoft Store, Homebrew, Anaconda, and
pyenvall manage versions differently - Number of installations: It's common — especially on developer machines — to have multiple Python versions installed simultaneously
- PATH configuration: The order of directories in your system's
PATHvariable determines whichpythonbinary your terminal finds first
Two developers on the same operating system can type the same command and get different version numbers, depending entirely on how Python was installed and configured on each machine.
The version you're actually working with — and the one that matters for your project — depends on your specific environment setup, not just what's on your system by default. 🔍