Data Science

How to Check Python Version on Windows, Linux, and MacOS


Vibha Gupta

Technical Content Writer at almaBetter

people9 mins


Published on23 Aug, 2023

Python is a widely-used programming language with multiple versions available. It is essential to know the version of Python installed on your system, as certain applications may require a specific version. This blog will explore how to check the Python version on Windows, Linux, and macOS operating systems. You will also learn the command to check Python version.

You can also learn Python for free with this Python tutorial.

Understanding Python Version Check

Python has several different versions, but the two most popular ones are Python 2.7.x and Python 3.7.x. You can perform the Python version check command that is mentioned below. The major version signifies significant changes and may not be fully compatible with previous versions. On the other hand, minor releases within the same major version are generally compatible with each other. The micro check Python version command represents the latest patches and updates.

It is worth noting that Python 2.7 will no longer receive security updates and patches after 2020. Python 3 includes a utility called "2 to 3" that helps translate Python 2 code into Python 3.

Why is it Important to Check Python Version?

To check Python version is crucial because different versions may have different syntax and functionalities. If you are working on a project that requires a specific version of Python, it is essential to ensure that your code is compatible. Additionally, some libraries and packages may only work with certain Python versions. By check Python version, you can avoid compatibility issues and ensure smooth execution of your code.

How to Check Python Version in Linux?

Most modern Linux distributions come with Python pre-installed. To check the version, open a terminal window and enter the following command:

python --version

The system will display the installed Python version.

Check Python Version in Windows

How to check Python version in cmd? By default, most Windows installations do not include Python. However, checking if Python is already installed on your system is always a good idea. To do so, open Windows Powershell and enter the following command:

python --version

If Python is installed, the version number will be displayed.

Alternatively, you can use the Windows Search function to check for the presence of Python version latest. Simply press the Windows key and type "Python". The search results will show the installed version, such as "Python 3.7 (32-bit)" or "Python 2.7 (32-bit)".

How to Check Python Version in Mac?

Check Python Version macOS - If you are using macOS, you can check Python version by opening the terminal and entering the following command:

python --version

The terminal will display the installed Python version.

Please note that in some cases, the command may return a screen full of information. In such cases, scan through the output to locate the word "python" followed by a version number, which represents the installed Python version.

Checking Multiple Versions of Python

It is possible to have multiple versions of Python installed on the same system. Python 2.7.x and Python 3.7.x can coexist, but they are different programs. To check for Python 2.7.x, use the following command:

python --version

To check the version of Python 3.x, use the following command:

python3 --version

Most systems differentiate between Python 2 and Python 3 by using the "python" command for Python 2.x and the "python3" command for Python 3.x. However, if Python 2 is not installed on your system, the "python" command may be used instead of "python3".

Checking Python Version in a Script

When developing an application, it can be helpful to check the Python version before running the code to ensure compatibility and prevent crashes. You can use the following code snippet to check for the correct version of Python:

import sys

if not sys.version_info.major == 3 and sys.version_info.minor >= 6:
    print("Python 3.6 or higher is required.")
    print("You are using Python {}.{}.".format(sys.version_info.major, sys.version_info.minor))

When executed, this script will check if Python 3.6 or a higher version is installed on the system. If not, it will display a notification and provide information about the current Python version.

Checking Python Version using Code

To check the Python version, you can use a simple line of code. You can also use the same command to check the Google Colab Python version or Google Colaboratory Python version. Open your Python interpreter or any Python IDE and type the following command:

import sys

This code will print the Python version installed on your system. The output will typically display the version number, followed by additional information such as build details and compiler information.

Upgrade Python Version

How to upgrade Python version or how to update Python version?

Python does not have a built-in upgrade system. To update Python version from the current Python version, you must download and install the latest Python version manually.

What are the Different Python Versions?

Python is a widely used high-level programming language known for its readability, simplicity, and versatility. Created by Guido van Rossum, Python was first released in 1991. It was designed with an emphasis on code readability, making it suitable for both beginners and experienced developers. Python's philosophy, often referred to as the Zen of Python, promotes a clean and readable coding style.

Over the years, Python has gone through several major releases, with improvements and enhancements in each version. The most notable transition occurred between Python 2 and Python 3, which brought significant changes and improvements while maintaining backward compatibility to some extent.

Python Version List:

Here's a table listing some of the major versions of Python, along with their release dates and key features:

VersionRelease DateNotable Features
0.9.0Feb 1991Initial release.
1.0Jan 1994Introduces lambda, map, filter, and reduce.
1.5Dec 1997Adds support for garbage collection and nested scopes.
2.0Oct 2000List comprehensions, garbage collection improvements.
2.5Sep 2006with statement, conditional expressions (PEP 308).
3.0Dec 2008Major overhaul: print function, bytes/strings distinction, etc.
3.5Sep 2015Async/await syntax, matrix multiplication, typing module.
3.6Dec 2016Formatted string literals, f-strings, typing improvements.
3.7Jun 2018Data classes, built-in breakpoint(), various improvements.
3.8Oct 2019Assignment expressions (walrus operator), f-strings improvements.
3.9Oct 2020Dictionary union operators, type hint improvements.

Please note that this table is not exhaustive and only includes selected major versions. The Python community continues to release new versions with enhancements and improvements beyond what's listed here.

As of my last update in September 2021, the latest stable version was Python 3.9. It's essential to visit the official Python website or other reliable sources for the most up-to-date information on Python versions and their features.

Python 2 vs Python 3

Python 2 and Python 3 are different versions of the Python programming language. Python 2 was released in 2000, and Python 3 was introduced in 2008. While both versions share many similarities, there are also significant differences between them. As of my last knowledge update in September 2021, Python 2 has reached its end of life and is no longer officially supported, so it's highly recommended to use Python 3 for all new projects. Here's a comparison of the two versions:

Print Statement vs. Print Function:

  • Python 2: Uses the print statement without parentheses.
  • Python 3: Requires the print() function with parentheses.


  • Python 2: Division of integers results in integer division (truncating the decimal part).
  • Python 3: Division of integers results in float division (retaining the decimal part). Integer division is done using //.


  • Python 2: Strings are treated as a sequence of bytes by default, causing issues with Unicode handling.
  • Python 3: Strings are Unicode by default, and handling of Unicode characters is much improved.

Range and xrange:

  • Python 2: Has both range() and xrange(). xrange() produces an iterator and is memory-efficient for large ranges.
  • Python 3: Only has range(), which behaves similarly to Python 2's xrange(). The concept of xrange() was merged into range().

Input Function:

  • Python 2: input() evaluates the input as Python code.
  • Python 3: input() returns the entered value as a string. To evaluate input, you use eval(input()).


  • Python 2: Iterating over dictionaries uses dict.iterkeys(), dict.itervalues(), and dict.iteritems().
  • Python 3: Dictionaries use the more Pythonic dict.keys(), dict.values(), and dict.items() for iteration.


  • Python 2: except syntax includes both the exception and variable (e.g., except Exception, e).
  • Python 3: except syntax separates the exception and variable with as (e.g., except Exception as e).

Type Annotations:

  • Python 2: Does not have built-in support for function parameter and return type annotations.
  • Python 3: Introduces function annotations using the -> syntax.

Integer Operations:

  • Python 2: Operations on integers return integers, which could lead to unexpected behavior in some cases.
  • Python 3: Division and other operations on integers always return floats when needed.

Bytes and Strings:

  • Python 2: Byte strings and Unicode strings are often confused, leading to encoding issues.
  • Python 3: Distinguishes between byte strings (bytes) and Unicode strings (str) more clearly.


  • Python 2: Implicit relative imports are possible and can sometimes lead to confusion.
  • Python 3: Explicit relative imports are required.

Library Compatibility:

Many libraries and frameworks have transitioned to Python 3, making it the preferred choice for modern development.

In summary, while Python 2 and Python 3 have many similarities, Python 3 offers improvements, better Unicode support, and more modern features. Since Python 2 is no longer supported, it's recommended to use Python 3 for any new projects to take advantage of its enhanced features and continued community support.

Troubleshooting Common Issues When Checking Python Version

While checking the Python version is a straightforward process, you may encounter some common issues along the way. Here are a few troubleshooting tips to help you resolve them:

1. Python command not recognized: If you receive an error stating that the Python command is not recognized, it means that Python is not properly installed or added to your system's PATH variable. To fix this, you can reinstall Python and make sure to check the option to add Python to PATH during the installation process.

2. Incorrect Python version displayed: In some cases, the Python version displayed may not match the version you expect. This can happen if multiple versions of Python are installed on your system, and the default version is different from the one you are checking. To resolve this, you can specify the Python version explicitly in the command prompt or IDE.

3. Module not found error: If you encounter a module not found error when running the code to check the Python version, it is likely that the 'sys' module is missing or not properly installed. You can reinstall Python or update your Python installation to include the missing module.


In this blog, we covered how to check the Python version on Windows, Linux, and macOS operating systems. It is crucial to know the installed Python version to ensure compatibility with different applications. Python 2.7.x and Python 3.7.x are the most popular versions, and it is important to understand their differences. Additionally, we discussed how to check multiple versions of Python and how to check the Python version within a script. Upgrading Python to a newer version requires downloading and manually installing the latest release. By following these steps, you can easily determine the Python version on your system and ensure compatibility with your programming needs.

Recommended Courses
Certification in Full Stack Data Science and AI
20,000 people are doing this course
Become a job-ready Data Science professional in 30 weeks. Join the largest tech community in India. Pay only after you get a job above 5 LPA.
Masters in CS: Data Science and Artificial Intelligence
20,000 people are doing this course
Join India's only Pay after placement Master's degree in Data Science. Get an assured job of 5 LPA and above. Accredited by ECTS and globally recognised in EU, US, Canada and 60+ countries.

AlmaBetter’s curriculum is the best curriculum available online. AlmaBetter’s program is engaging, comprehensive, and student-centered. If you are honestly interested in Data Science, you cannot ask for a better platform than AlmaBetter.

Kamya Malhotra
Statistical Analyst
Fast forward your career in tech with AlmaBetter

Vikash SrivastavaCo-founder & CPTO AlmaBetter

Vikas CTO
Made with heartin Bengaluru, India
  • Official Address
  • 4th floor, 133/2, Janardhan Towers, Residency Road, Bengaluru, Karnataka, 560025
  • Communication Address
  • 4th floor, 315 Work Avenue, Siddhivinayak Tower, 152, 1st Cross Rd., 1st Block, Koramangala, Bengaluru, Karnataka, 560034
  • Follow Us
  • facebookinstagramlinkedintwitteryoutubetelegram

© 2023 AlmaBetter