How to check Python Version : Windows, Linux and Mac
Last Updated :
22 Apr, 2025
Python has multiple versions, and it's important to know which version is installed on your system. This information is crucial because different Python versions may have variations in syntax or libraries, and ensuring you're using the correct version is vital for compatibility with your projects. In this guide, we'll explore various straightforward methods on how to check the Python version on your Linux, Windows, and Mac systems.
How to Check Python Version on Windows and Mac
To check the Python version on Windows or Mac system, we can follow these methods:
- Using the Command Prompt/Terminal
- Checking in the Interactive Shell
Using the Command Prompt/Terminal
Open the Command Prompt for Windows by searching for "cmd" in the Windows Start menu or open Terminal for Mac by searching Terminal in the MacOS spotlight search. Then, use one of the following commands:
For Python 2:
python --version
or
python -V
For Python 3:
python3 --version
or
python3 -V
python Version using Command PromptUsing Interactive Shell
We can also find the Python version in the interactive shell. Open the Command Prompt/terminal and enter one of the following commands:
For Python 2:
python
For Python 3:
python3
Once you are in the Python interactive shell, you can check the version with these Python commands:
import sys
print(sys.version)
Python Version Using Interactive ShellHow to Check Python Version on Linux
We can use the following methods to check the Python version on Linux systems like Ubuntu, Debian, Arch, etc. These methods can be used to find Python version:
- Using the Command Line
- Checking in the Interactive Shell
- Using Package Managers
- Checking the Path
Check the Python Version Using the Command Line
The command line provides a straightforward way to get the Python version. Open your terminal and use this simple check Python version command:
For Python 2:
python --version
or
python -V
For Python 3:
python3 --version
or
python -V
Check Python Version Using the Command LineNOTE: These commands will display the Python version installed on your Linux system.
Check Python Version Using Interactive Shell
Python's interactive shell is another way to find Python version. Open your terminal and enter one of the following commands:
For Python 2:
python
For Python 3:
python3
Once you are in the Python interactive shell, you can get Python version with the following Python commands:
import sys
print(sys.version)
Checking Python Version in the Interactive ShellCheck Python Version Using Package Managers
If you installed Python using a package manager, you can use these tools to check the Python version.
For Debian-based systems, such as Ubuntu, you can use `apt`:
apt show python3
Check Python Version Using Package ManagersFor Red Hat-based systems, like CentOS, you can use yum:
yum info python3
NOTE: These commands will provide detailed information about the Python version installed on your system.
Finding Python Version by Checking the Path
We can also determine the path to the Python interpreter and indirectly obtain information about the installed version using the `which` command:
which python3
This command will return the path to the Python interpreter. We can then use this path to check the version:
/path/to/python --version
Replace '/path/to/python' with the actual path obtained from the previous which command.
Finding Python Version by Checking the PathAlso Read:
Similar Reads
How to Check yfinance version in Python It is a financial data library for developers that provides a simple and convenient way to access historical market data from Yahoo Finance. It allows users to download stock price data, financial statements, and other relevant financial information for analysis and trading. With its easy-to-use int
2 min read
How to Check OpenCV Version in Python OpenCV (Open Source Computer Vision Library) is a powerful library for computer vision and image processing tasks. Whether you're a beginner or an experienced developer, knowing how to check the version of OpenCV you're using can be essential for compatibility and troubleshooting. In this article, w
3 min read
How to Upgrade Pip and Python on Windows, Linux, and MacOS? Python is a programming language with standard libraries and a great ecosystem of third-party packages. On the other side, Pip is the default package manager for Python that installs, upgrades and manages Python, including its dependencies. Pip simplifies the process of installing external libraries
5 min read
How to download and install Python Latest Version on Windows Python is a widely-used general-purpose, high-level programming language. This article will serve as a complete tutorial on How to download and install Python latest version on Windows Operating System. Since windows don't come with Python preinstalled, it needs to be installed explicitly. In window
2 min read
How to add Python to Windows PATH? Python is a great language! However, it doesnât come pre-installed with Windows. Hence we download it to interpret the Python code that we write. But wait, windows donât know where you have installed the Python so when trying to any Python code, you will get an error. We will be using Windows 10 and
2 min read
How to use CMD for Python in Windows 10 Want to run Python programs directly from the Command Prompt? This guide will walk you through how to run Python in CMD, configure the environment, and troubleshoot common issues. By mastering these steps, youâll streamline your development process and save time during testing.Steps to Use CMD for P
4 min read