Python is a versatile and widely used programming language, and it is used for various tasks, from scripting to web development. Python, like many software, has different 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, giving you the confidence that you’re working with the right Python interpreter for your specific needs.
Check the Python Version on Linux
Linux is a popular platform for Python development and system administration. 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 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 Line
NOTE: 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 Shell
Check 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 Managers
For 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
You 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. You 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 Path
Check Python Version on Windows and Mac
Python is widely used on Windows and Mac for application development, data analysis, and more. To check the Python version on Windows or Mac system, you can follow these methods:
- Using the Command Prompt/Terminal
- Checking in the Interactive Shell
Finding the Python Version 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
These commands will display the Python version installed on your Windows/ Mac system.
Check the Python Version Using Interactive Shell
You 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
the
python3
Once you are in the Python interactive shell, you can check the version with these Python commands:
import sys
print(sys.version)
This will display detailed information about your Python version.
Also Read:
Conclusion
In this article, we discussed how to check the Python version on Linux, Windows, and macOS (Mac). Knowing your Python version is crucial for compatibility with your projects, as different versions may have variations in syntax and libraries.
By following the provided methods, you can confidently determine the Python version on your system, ensuring you’re using the right interpreter for your specific needs on your chosen platform. Whether you’re a developer, system administrator, or Python enthusiast, understanding your Python version is fundamental to your work.
How to check Python Version : Windows, Linux and Mac – FAQs
How Do I Check What Version of Python I Have on My Mac?
To check the Python version on your Mac, you can open the Terminal application and type the following command:
python --version
or
python3 --version
The command you use depends on how Python was installed and whether you are using Python 2 or Python 3. The python3 command is more likely to be used for Python 3, especially on newer installations.
How Do I Check Python Version in Windows?
To check the Python version on a Windows machine, open Command Prompt and type:
python --version
or
python3 --version
This will display the installed Python version. Again, which command you use depends on your configuration and how Python was installed.
How to Check Python Version in Linux?
To check the Python version on a Linux system, open a terminal window and enter:
python --version
or
python3 --version
As with macOS and Windows, whether you use python or python3 depends on your specific installation and setup preferences, especially since many Linux distributions are moving to Python 3 as the default.
How Do I Check the Version of a Python Package on a Mac?
To check the version of a Python package installed on your Mac, you can use pip, Python’s package installer. Open the Terminal and type:
pip show <package_name>
or, for Python 3,
pip3 show <package_name>
This command will display information about the package, including its version.
Does My Mac Already Have Python?
Yes, macOS typically comes with Python pre-installed. Historically, this has been Python 2.7, but with recent macOS versions, Python 3 might also be pre-installed or no Python at all starting with macOS Monterey. To check if and what version of Python is installed, open the Terminal app and type:
python --version
and/or
python3 --version
This will show you which version(s) of Python are currently installed on your system. If Python 3 is not installed, you can install it via Homebrew (a package manager for macOS) by running:
brew install python3
Please Login to comment...