How to Check Python Version in Windows, Linux, and macOS [2023]

Python is one of the most famous programming languages as it is used across different domains such as web development, machine learning, data analytics, and software testing, to mention just a few.
Python was released on February 20, 1991, by Guido van Rossum. As Rossum was creating Python, he was also reading “Monty Python’s Flying Circus”, a script of a popular BBC comedy series. He thus settled on the name as he considered the new language mysterious and unique.
This general-purpose programming language has a wide variety of users, and you may have interacted with it unknowingly through the movie recommendations on Netflix. Python is also used in the creation of software that controls self-driving cars.
Some of the things you can do with Python are
- Web development. Python is used in backend development (the processes that users don’t see). Flask and Django are examples of frameworks that are widely used in the development of APIs and backend servers.
- Automation or scripting. If there is a job that you find yourself performing repeatedly, Python can help you automate it. Beginners, as well as experts, can use Python to automate various tasks such as sending emails, finding data online, sorting data, and downloading.
- Data analysis and machine learning. Python has become one of the most sought programming languages by data scientists. Data analysts can now create data visualizations, conduct complex statistical calculations, manipulate & analyze and so much more.
- Software testing and prototyping. In a software development setup, Python can be used in bug tracking, testing, and build control. Developers can automate tests and checks on new systems and apps using Python.
- Business applications. The business world is wide, and some of the things that may come to mind are e-commerce applications, customer management systems, and ERP, to mention a few. A typical business setting will need applications that are easily readable, extensible, and scalable. Python offers such a solution through its platforms, such as Tryton.
Why is Python so Popular
- It is versatile. If you have interacted with other languages, you may have noted that some have a single or just two use cases. However, Python has more than five use cases, and still, its performance is unmatched.
- Has multiple libraries and modules. There exist tons of libraries and modules created by third parties to expand on the use cases of Python. For instance, you can use Django for server-side web development.
- Python is simple. This programming language mimics the natural language, making it suitable for even beginners.
- Large and active community. Programming can be challenging at times. However, the presence of a big and supportive community means that there are people you can always turn to when you get stuck.
- Open-source. Python is free to use and distribute. Engineers can thus tweak existing code, redistribute and create various solutions/ applications with it.
Python 2 and Python 3: Difference
Python programming language has evolved a lot over the more than 3 decades that it has been in existence. One of the reasons you may want to check the Python version is to determine if you are using Python 2 or Python 3 to ensure that you build bug-free solutions, irrespective of whether you are a developer or a data expert.
Python 2 and Python 3 are the major versions in the Python world. There has been an ongoing debate on which is better. Let us check the difference between the two;
Python 2
Python 2 was introduced in 2000 by BeOpen Python Labs. This version was intended to make learning Python easy.
It was through Python 2 that the technical details of the Python Enhancement Proposal (PEP) were implemented. In January 2020, Python 2 was sunsetted, which means it will no longer be updated with security patches, new features, and bug fixes.
Python 3
Python 3 was released in 2008. This version was created to rectify the fundamental Python 2’s flaws. Python 3 did away with duplicate modules and constructs that were in the previous Python versions.
The removal of duplicate tools with the introduction of Python 3 meant some of the code in Python 2 was incompatible with Python 3. Luckily, Python released 2to3, a tool that reviews and automatically converts Python 2 code to Python 3 syntax.
The introduction of this version attracted a big mass of the scientific community, such as those in neuroscience. The introduction of the NumPy library now posed Python as a competitor to Matlab and R and also accelerated its adoptions in data science and machine learning. At the time of writing, the current version of Python is Python 3.11.1.
| Comparison | Python 2 | Python 3 |
| Year released | 2000 | 2008 |
| Support | Supported stopped in 2020 | Development and support of Python 3 is still ongoing |
| Backward compatibility | With some modifications, Python 2 codes can be ported to Python 3 | Python 3 code can’t be run on Python 3 |
| Application | It was mostly used in DevOps | Python is multipurpose and applicable in software engineering, data science, and so much more |
| “Print” keyword | Print is not considered a function but a statement | Print is considered a function and not a statement |
| Syntax complexity | More complicated | Less complicated |
| Storage of strings | By default, strings are stored as ASCII | By default, strings are stored as UNICODE |
Prerequisites to check the Python Version
You can access the terminal window/ terminal using these commands on Windows, Linux, and macOS, respectively;
- Windows: Win+R > type powershell > Enter/OK
- Linux: Ctrl-Alt-T, Ctrl-Alt-F2
- macOS: Finder > Applications > Utilities > Terminal
Since now you know that there are two major versions of Python, we can go ahead and learn how to check the version on our local machines.
Python 3 is backward incompatible. Python 2 and Python 3 are different pieces of software. It thus means that code written in Python 2 may not work as expected in Python 3.
When you check the Python version on your machine, the version will be represented in 3 sections separated by a dot.
- The major version
- The minor version
- The micro version
For instance, if we take the Python version, Python 3.8.10, 3 is the major version, 8 is the minor version, and 10 is the micro version. The last section of the Python version represents the latest updates and patches.
Python 3.7.1 is compatible with Python 3.8.10 as they belong to the same major version (3). However, Python 2.7 is not compatible with Python 3.8.
Check Python Version on Windows
Open Windows PowerShell using these steps;
Win+R > type powershell > Enter/OK
You can now go ahead and type this on the command line
If Python is installed on your machine, the version will appear on the next line.

Check Python Version on Linux
Most modern Linux operating systems have Python pre-installed.
Use the Ctrl+Alt+T shortcut to open the command line on your Linux-based machine.
Use this command to print the Python version;
The second command checks if Python 2 is installed
If Python 3 is installed, you are likely to get something like this

Check Python Version on MacOS
You can quickly access your terminal in MacOS using this shortcut;
Finder > Applications > Utilities > Terminal
Use this command to check the Python version;
The second command checks if Python 2 is installed
If you have both Python 2 and 3 installed, you will get an output close to this

Check Python Version in the Script
It is important to check the Python version on your script when coding to avoid incompatibilities and crushes when you run the code.
Such a check is very important when you have more than one Python version on your PC.
Irrespective of whether you are using Windows, Linux, or macOS, you can use this command to check your script
What happens if the same machine has two different versions of Python installed and you run the above-mentioned commands?
Python 2 and Python 3 can run concurrently on your PC. The reason for this is that you may have some apps that are using Python 2 while others are created on Python 3.
To check whether the two Python versions are on your PC, use these commands;
The second command checks if Python 2 is installed
If both versions are present on macOS, you will get an output close to this screenshot

Conclusion
Python continues to power some of your favorite social media platforms, such as Instagram, entertainment sites, such as Spotify, and rides management platforms, such as Uber. If you need to create platforms creating similar or better platforms, Python should be one of your considerations.
You can now comfortably check the Python version irrespective of the operating systems you are using. Even though most are shifting to Python 3, you will still come across apps created on Python 2. The good news is that Python has various frameworks that you can use to create different applications.
You may also explore how to install Python 3 on CentOS, Ubuntu, and Windows.
Which version of Python do I have installed?
I have to run a Python script on a Windows server. How can I know which version of Python I have, and does it even really matter?
I was thinking of updating to the latest version of Python.
![]()
![]()
26 Answers 26
—version may also work (introduced in version 2.5)
![]()
In a Python IDE, just copy and paste in the following code and run it (the version will come up in the output area):
![]()
![]()
![]()
At a command prompt type:
Or if you have pyenv:
![]()
![]()
Although the question is «which version am I using?», this may not actually be everything you need to know. You may have other versions installed and this can cause problems, particularly when installing additional modules. This is my rough-and-ready approach to finding out what versions are installed:
The output for a single Python installation should look something like this:
How to Check Python Version?
Before learning how to check the python version, we should first understand Python and its versions briefly.
Python is an object-oriented, high-level interpreted scripting language.
Let us discuss some of the various important points regarding the Python programming language :
- Python programming language is a highly readable language making it easy to understand for new coders.
- ABC programming language can be considered the predecessor of the Python programming language. Modula-3 also has some influence on the Python programming language.
- The Python programming language was developed by Guido Van Rossum in the Netherlands in 1991.
- Python language is widely used in various technical fields such as Artificial Intelligence (AI), Machine Learning (ML), Scientific Calculation, Desktop Application, Web Development (using Django , and Flask framework, etc.) Mobile Application Development, etc.
Let us learn how to check the python version using the command line and scripts.
Check Python Version: Command-Line
Let us first learn how to check the python version using the various command-line commands used in different operating systems.
i) Windows:
In Windows operating systems, we can use the command python —version to check the python version.
The steps to check the python version in Windows are very simple:
- Open the Windows command prompt or Windows Powershell, and enter the following command on the shell :
If we have a Python interpreter installed on the Windows operating system then the command will show the version like :
Output :
Note :
- The version number may differ, but if the Python interpreter is installed in a system, it will similarly show the version.
- We can also search for Python present on the system. We can press the Windows key to launch the search menu and then we can type Python. If the system has installed Python, it will show the Python version.|
ii) MacOS :
In macOS operating systems, we can use the same command, python —version , to check the python version.
The steps to check the python version in macOS are very simple:
- Open the macOS Terminal, and enter the following command on the shell or terminal :
If we have a Python interpreter installed on the macOS operating system, then the command will show the version like :
Output :
iii) Linux :
In Linux operating systems, we can use the same command, python —version to check the python version.
The steps to check the python version in Linux are very simple:
- Open the Linux terminal or shell and type the following command :
If we have a Python interpreter installed on the Linux operating system, then the command will show the version like :
Output :
Note:
We can use the commands such as python —version or python -v or python -VV . All of these commands will provide a similar result. The -VV option is a new command added since Python 3.6 . Which can be used for detailed information than -V or —version .
Check Python Version: Script
Let us now learn how to check the python version using scripts. We can use the sys module or the platform module of the standard library to check the python version in various operating systems. The script will be the same for all operating systems such as Windows , Mac , Linux , etc.
The script is very useful for checking the python version even tho we have various versions of Python installed on our system. Let us see the script and its related information.
i) Various information string: sys.version :
We can use the .version method in the sys (system) module to print the version of the Python interpreter installed on the system. The sys. version method returns a string that contains the version number of the Python interpreter installed in the system. It also returns additional information about the build number and the compiler used.
let us now look at the script :
Output :
ii) Tuple of version numbers: sys.version_info :
We can also use the .version_info method in the sys (system) module to print the version of the Python interpreter installed on the system. The sys.version_info method returns a tuple containing five components of the Python interpreter version number: the major version release number, the minor version release number, the micro version release number, the release level, and the serial number.
let us now look at the script :
Output :
Note :
The release level element is a string, and the other output elements are integers.
iii) Version number string: platform.python_version() :
We can also use the .python_version() method present in the platform module to print the version of the Python interpreter installed on the system. The platform.python_version() method returns a string in the form major.minor.patchlevel . The string denotes the major release number then the minor release number, and then the patch level, each separated using a dot( . )
let us now look at the script:
Output :
The script is handy when we want to check the Python interpreter version number as a simple string only.
iv) Tuple of version number strings: platform.python_version_tuple() :
We can also use the .python_version_tuple() method present in the platform module to print the version of the Python interpreter installed on the system. The platform.python_version_tuple() method returns a tuple in the form 'major', 'minor', 'patchlevel' . The tuple denotes the major release number, then the minor release number, and then the patch level, each separated using a comma( , ). Each element of the tuple is in the form of a string.
let us now look at the script:
Output :
What are the Different Python Versions?
We have already discussed what Python programming language is and how to check the python version, let us briefly discuss the various popular versions of the Python programming language.
- The first version of Python was released in 1994 named Python 1.0 . Python 1.0 had various features like lambda function, map , filter , reduce , etc.
- The second version of Python was released in 2000, with many major new features such as garbage collection systems, list comprehensions, etc.
- The third and latest major Python version release was released in 2008. This version of Python ( Python 3.0 ) is also known as Py3K.
Refer to the below-specified table to check the various Python interpreter versions and their release dates.
| Python Versions | Release Date |
|---|---|
| Python 1.0 | January 1994 |
| Python 1.5 | December 31, 1997 |
| Python 1.6 | September 5, 2000 |
| Python 2.0 | October 16, 2000 |
| Python 2.1 | April 17, 2001 |
| Python 2.2 | December 21, 2001 |
| Python 2.3 | July 29, 2003 |
| Python 2.4 | November 30, 2004 |
| Python 2.5 | September 19, 2006 |
| Python 2.6 | October 1, 2008 |
| Python 2.7 | July 3, 2010 |
| Python 3.0 | December 3, 2008 |
| Python 3.1 | June 27, 2009 |
| Python 3.2 | February 20, 2011 |
| Python 3.3 | September 29, 2012 |
| Python 3.4 | March 16, 2014 |
| Python 3.5 | September 13, 2015 |
| Python 3.6 | December 23, 2016 |
| Python 3.7 | June 27, 2018 |
| Python 3.8 | October 14, 2019 |
How to Upgrade to a Newer Version?
We can easily upgrade to the latest or newer version of the Python interpreter by simply going to the (visiting) Python downloads page and downloading the latest version.
What if Your Computer has Multiple Python Versions Installed?
We can have multiple Python interpreter versions installed on our system. We can run a particular python program (or python script) using the specified Python interpreter version.
For example, if we have Python 2.6 and Python 3.6 installed on our system, then we can run a file (let's say program.py ) using both interpreters.
Example : (For Python 3.6)
Example : (For Python 2.6)
Python 2 vs Python 3
Both Python 2 and Python 3 are very popular interpreters, let us discuss some of the major differences between both releases.
| Python 2 | Python 3 |
|---|---|
| Python 2 was released in 2000. | Python 3 was released in 2008 . |
| Python 2 interpreter considers print as a statement but not a function. | Python 3 interpreter considers print() as a function. |
| The strings are by default stored as UNICODE characters in Python 2 . | The strings are by default stored as ASCII characters in Python 2 . |
| The division of two integral values in Python 2 results in another integral value. For example, 7/2 yields 3 . | The division of two integral values in Python 3 results in a floating-point value. For example, 7/2 yields 3.5 |
| Exception in Python 2 was dealt with in the enclosed notations. | Exceptions in Python 3 are enclosed in parentheses. |
| We used the xrange() function for iteration in Python 2 . | We use the range() function for iteration in Python 3 . |
| Python 2 is not longer in use since the year 2020 . | Python 3 is more popular than Python 3 but in some places, we still use Python 2 . |
| With some effort, we can port the Python 2 code to Python 3 . | Python 3 has no backward compatibility with the previous version i.e. Python 2 .> |
Learn More
To learn more about the Python Programming Language, refer to the articles :
Check the Version of the Python Interpreter
In this article, we will get to know the current version of the Python interpreter in the system. Getting the version of the interpreter is really important as the Python interpreter is widely used throughout the industries for computer programming and source coding. It takes an interactive command and executes it.
As the interpreter is the one who takes the code and helps in execution. Sometimes the old version of the interpreter-making command doesn’t work properly and as we know the language Python comes with frequent update vision with some added new features, so the user must update the interpreter with the latest release version.
Check Python Version for Mac, Windows, and Linux
Check Python version on Command Line
This method is one of the simplest methods among all other methods as in this method users get the current Python version with one of the inbuilt commands present in Python. Here are some steps that the user must follow to get the currently running version of the Python interpreter:
- Open cmd/terminal/windows PowerShell.
- Now, write the same command as mentioned below in the code box given, and press enter, with this it will return the current Python interpreter version in the form of a string.
Output:

Python Version Check
Check Python Version in Script
For this method, the user needs to import the sys library from sys. version command which will return the user’s current Python version in use. For this method, the user must open the Python shell and write the following command as given below, with this command the user will get the current working version of the Python interpreter in the form of a string. Here is some step that the user must follow to get the currently running version of the Python interpreter: