How to check python version

Content on WhatAnswers is provided "as is" for informational purposes. While we strive for accuracy, we make no guarantees. Content is AI-assisted and should not be used as professional advice.

Last updated: April 4, 2026

Quick Answer: You can check your Python version by opening your terminal or command prompt and typing `python --version` or `python -V`. If you are using Python 3 specifically, you might need to use `python3 --version` or `python3 -V` depending on your system's configuration.

Key Facts

What is a Python Version?

A Python version refers to a specific release of the Python programming language. Like other software, Python undergoes continuous development, with new features, bug fixes, and performance improvements introduced in subsequent versions. These versions are typically denoted by a numbering system, such as 3.9.7, where the numbers represent major, minor, and patch releases respectively. Understanding your Python version is essential for several reasons, including ensuring compatibility with libraries and frameworks you intend to use, accessing the latest language features, and maintaining security through updated patches.

How to Check Your Python Version in the Terminal/Command Prompt

The most straightforward method to determine which Python version is installed on your system is by using your command-line interface (CLI). This applies to Windows, macOS, and Linux operating systems.

Using the `python --version` Command

Open your terminal (on macOS/Linux) or Command Prompt/PowerShell (on Windows). Then, type the following command and press Enter:

python --version

If Python is installed and configured correctly in your system's PATH, this command will output the installed Python version. For example, you might see something like:

Python 3.10.4

Using the `python -V` Command

An alternative command that achieves the same result is:

python -V

Note that the 'V' must be capitalized.

Handling Multiple Python Versions (Python 2 vs. Python 3)

In some environments, especially older macOS and Linux systems, typing `python` might default to Python 2. If you specifically installed Python 3 and want to check its version, you might need to use the `python3` command:

python3 --version

or

python3 -V

This ensures you are checking the version of Python 3 installed on your system. If neither `python --version` nor `python3 --version` works, it might indicate that Python is not installed or not added to your system's PATH environment variable.

How to Check Python Version Programmatically within a Script

If you need to check the Python version from within a Python script itself, you can use the built-in `sys` module. This is particularly useful when you need to ensure your script runs on a minimum required version or adapt its behavior based on the Python version.

Using the `sys` Module

Create a Python file (e.g., `check_version.py`) and add the following code:

import sysprint("Python Version:")print (sys.version)print("Version info:")print (sys.version_info)

Run this script from your terminal using:

python check_version.py

The output will provide detailed information about the Python version, including the version number, build date, and compiler used. For instance:

Python Version:3.10.4 (main, Mar 23 2022, 23:05:04) [Clang 13.1.6 (clang-1316.0.21.2.5)]Version info:sys.version_info(major=3, minor=10, micro=4, releaselevel='final', serial=0)

The `sys.version_info` provides a named tuple that is easier to parse programmatically, allowing you to check for specific major, minor, or micro versions.

Why Knowing Your Python Version Matters

Several factors make knowing your Python version important:

Troubleshooting Common Issues

If the commands `python --version` or `python3 --version` do not work, consider the following:

By following these steps, you can easily determine your Python version and ensure your development environment is set up correctly.

Sources

  1. sys — System-specific parameters and functions - Python documentationCC-BY-SA-4.0
  2. How to Check Python Version - Real Pythonfair-use
  3. Download Python | Python.orgfair-use

Missing an answer?

Suggest a question and we'll generate an answer for it.