---
description: Python scripts can identify the version of Python installed on the computer. It enables you to validate if multiple versions are installed in the system.
title: How to Check Python Version on Linux, Mac &amp; Windows
image: https://www.guru99.com/images/how-to-check-python-version.png
---

[Skip to content](#main)

**⚡ Smart Summary**

Python version tells you which release is installed to ensure compatibility with your code and libraries. The examples below show how to check it on Windows, Linux, and Mac using the command line, PowerShell, and scripts.

- 🔍 **Quick Check:** Run python –version in the command line or terminal to see the installed version.
- 📜 **Script Method:** Use the sys or platform module inside a Python script to read the version.
- 🪟 **Windows:** Check the version from Command Prompt or PowerShell.
- 🐧 **Linux and Mac:** Use the terminal with python –version or python3 –version.
- 🔢 **Multiple Versions:** You can detect several Python versions installed on the same system.
- ⚠️ **Python 2 vs 3:** The two versions use different syntax, so knowing the version matters.

Read More

![How to Check Python Version](https://www.guru99.com/images/how-to-check-python-version.png)

## How to Check Python Version

Here are check the Python version using a script

[![Check Python Version](https://www.guru99.com/images/3/check-python-version-1.png)](https://www.guru99.com/images/3/check-python-version-1.png)

| Commands | Where | What | Output |
| --- | --- | --- | --- |
| python –version<br> python -v<br> python -vv | Command line or Terminal | Windows/Mac/Linux | Python 3.10.7 |
| Import sys<br> sys. version | Script | Use as string | ‘3.10.7 (tags/v3.10.7:6cc6b13, Sep 5 2022, 14:08:36) \[MSC v.1933 64 bit (AMD64)]’ |
| Import platform<br> Platform.python\_version() | Script | String of short format | ‘3.10.7’ |
| Platform.python\_version\_tuple() | Script | Tuple of short format | (‘3’,’10’,’7’) |

## How to check the Python version using a script?

[Python scripts](https://www.guru99.com/run-python-scripts.html) can identify the version of Python installed on the computer. It enables you to validate if multiple versions are installed in the system. The script developed to check the Python version remains the same for windows OS, Mac OS, and Linux distributions. You can create a script by importing either the platform module or sys module of python.

The following code can be used for the sys module as shown below:

**Command line Code:**

```
import sys
sys. version
```

**Output:**

```
'3.10.7 (tags/v3.10.7:6cc6b13, Sep 5 2022, 14:08:36) [MSC v.1933 64 bit (AMD64)]'
```

Refer to the following command line screenshot:

[![Check the Python Version using a Script]()](https://www.guru99.com/images/3/check-python-version-21.png)

To execute the above script, invoke python first in the command line to get the above results.

The following code can be used for the sys module as shown below:

**Command line Code:**

```
import platform
print(platform.python_version())
```

**Output:**

```
3.10.7
```

Refer to the following command line screenshot:

[![Check the Python Version using a Script]()](https://www.guru99.com/images/3/check-python-version-3.webp)

Use the following code in the web-based interpreter as shown below: –

**Python code:**

```
from platform import python_version

print("Current Python Version-", python_version())
```

**Output:**

```
Current Python Version- 3.8.10
```

Refer to the following web-based interpreter screenshot:

[![Check the Python Version using a Script]()](https://www.guru99.com/images/3/check-python-version-4.webp)

[![Check the Python Version using a Script]()](https://www.guru99.com/images/3/check-python-version-5.webp)

To get the information on the version of python, use the following script as shown below:

**Python command:**

```
print(sys.version_info)
```

**Output**

```
Sys.version_info(major=3, minor=10,micro=7,releaselevel=’final’,serial=0)
```

**Screenshot**

[![Check the Python Version using a Script]()](https://www.guru99.com/images/3/check-python-version-6.webp)

To get the tuple information on the version of python, use the following script as shown below: –

**Python command**

```
print(type(sys.version_info))
```

**Output**

```
<class ‘sys.version_info’>
```

**Screenshot**

[![Check the Python Version using a Script]()](https://www.guru99.com/images/3/check-python-version-7.webp)

To get the major information on the version of python, use the following script as shown below: –

**Python command**

```
print(sys.version_info[0])
```

**Output**

```
3
```

**Don't Miss:**

- [PyQt5 Tutorial with Examples: Create Python GUIs with Qt](https://www.guru99.com/pyqt-tutorial.html)
- [Python abs() Function: Absolute Value Examples](https://www.guru99.com/abs-in-python.html)
- [type() and isinstance() in Python with Examples](https://www.guru99.com/type-isinstance-python.html)
- [Python Program to Find the Factorial of a Number](https://www.guru99.com/python-factorial-example.html)

**Screenshot**

[![Check the Python Version using a Script]()](https://www.guru99.com/images/3/check-python-version-8.webp)

**Python command**

```
print(sys.version_info.major)
```

**Output**

```
3
```

**Screenshot**

[![Check the Python Version using a Script]()](https://www.guru99.com/images/3/check-python-version-9.webp)

To get the information on the platform python, use the following script as shown below: –

**Python command**

```
Import platform
print(platform.python_version())
```

**Output**

```
3.10.7
```

**Screenshot**

[![Check the Python Version using a Script]()](https://www.guru99.com/images/3/check-python-version-10.webp)

To get the type information on the platform version of python, use the following script as shown below: –

**Python command**

```
print(type(platform.python_version()))
```

**Output**

```
<class ‘str’>
```

**Screenshot**

[![Check the Python Version using a Script]()](https://www.guru99.com/images/3/check-python-version-11.webp)

To get the tuple information on the version of python, use the following script as shown below: –

**Python command**

```
print(platform.python_version_tuple())
```

**Output**

```
(‘3’,’7’,’0’)
```

**Screenshot**

[![Check the Python Version using a Script]()](https://www.guru99.com/images/3/check-python-version-12.webp)

**Python command**

```
print(type(platform.python_version_tuple())
```

**Output**

```
<class ‘tuple’>
```

**Screenshot**

[![Check the Python Version using a Script]()](https://www.guru99.com/images/3/check-python-version-13.webp)

## How to check the Python version using Windows Command Line?

Here are steps to check the Python version using Windows Command Line:

**Step 1)** Open the command prompt by typing cmd

**Step 2)** When the command prompt opens, type the following command in the CLI to get the version name of Python.

**Command code:**

```
python3 --version
```

**Output:**

```
Python 3.10.7
```

**Note:** Before running the command, ensure that Python is pre-installed on the computer.

Alternatively, open a command line and type the below command:

**Command code:**

```
python --version
```

**Output:**

```
Python 3.10.7
```

Refer to the below screenshot for the results executed in the command prompt:

**Screenshot:**

[![Check the Python Version using Windows Command Line]()](https://www.guru99.com/images/3/check-python-version-14.webp)

## How to check the python version using windows PowerShell?

To check the Python version in Windows PowerShell:

- Open the power shell prompt by typing PowerShell in the start menu and clicking on Windows PowerShell.
- The user must type the following command in [PowerShell](https://www.guru99.com/powershell-tutorial.html) to obtain the Python version name.

[![Check the Python Version using Windows Command Line]()](https://www.guru99.com/images/3/check-python-version-15.webp)

However, before running this command, ensure that Python is pre-installed on the computer.

Following is the command typed in the command line:

**PowerShell code:**

```
python3 --version
```

**Output:**

```
Python 3.10.7
```

Alternatively, open a command line and type the below command:

**PowerShell code:**

```
python --version
```

**Output:**

```
Python 3.10.7
```

See this screenshot for the results executed in the command prompt:

[![Check the Python Version using Windows Command Line]()](https://www.guru99.com/images/3/check-python-version-16.webp)

## How to check the Python Version in Linux?

Here are steps to check the Python Version in Linux:

**Step 1)** To check the Python version in Linux, open the Terminal

**Step 2)** This opens the below window as shown below:

[![Check the Python Version using Windows Command Line]()](https://www.guru99.com/images/3/check-python-version-17.webp)

**Step 3)** Type the below command in the Terminal of Linux to get the version name of Python.

Following is the command typed in the Terminal:

**Linux Terminal code:**

```
python3 --version
```

**Output:**

```
Python 3.5.2
```

Alternatively, open the Terminal and type the below command:

**Linux terminal code:**

```
python --version
```

**Output:**

```
Python 2.7.12
```

The above command helps the user check whether python 2 is installed in the system. Refer to the below screenshot for the results executed in the Linux terminal:

**Screenshot:**

[![Check the Python Version using Windows Command Line]()](https://www.guru99.com/images/3/check-python-version-18.webp)

Ensure that Python is pre-installed on the operating system of the computer. Most advanced versions of Linux distributions, such as Ubuntu and Fedora, have Python pre-installed in it.

Alternatively, the following commands can be used in the Linux terminal to get the version name of the Python installed in the distribution as listed below: –

**Linux terminal code:**

```
python -VV
```

**Output**

```
Python 2.7.12
```

**Screenshot: –**

**Linux terminal code:**

```
Python3 -c “import sys; print(sys. version).”
```

**Output**

```
3.5.2(default, Nov 12 2018, 13:43:14)

[GCC 5.4.0 20160609]
```

**Screenshot:**

[![Check the Python Version using Windows Command Line]()](https://www.guru99.com/images/3/check-python-version-19.webp)

**Linux terminal code:**

```
Python3 -c “import sys; print(sys.version_info)”
```

**Output**

```
sys.version_info(major=3,minor=2,releaselevel=’final’,serial=0)
```

**Screenshot:**

[![Check the Python Version using Windows Command Line]()](https://www.guru99.com/images/3/check-python-version-20.webp)

**Linux terminal code:**

```
Python3 -c “import platform; print(platform.python_version())”
```

**Output**

```
3.5.2
```

**Screenshot:**

[![Check the Python Version using Windows Command Line]()](https://www.guru99.com/images/3/check-python-version-21.webp)

The only difference in the above commands is the use of python modules. This module provides names for variables and functions that are used to manipulate different parts of the Python environment. The module gets underlying platform data such as operating system, hardware, and interpreter.

## How to check the Python version on Mac?

Here are steps to check the Python version:

**Step 1)** To check the Python version in Mac OS

Open the Terminal by typing the terminal command in the search box in the top right corner of the Mac OS desktop menu and click on it.

**Step 2)** This opens the below window as shown below:

[![Check the Python Version using Windows Command Line]()](https://www.guru99.com/images/3/check-python-version-22.webp)

**Step 3)** To obtain the Python version name, you need to use the following command in the Terminal window.

**Note:** However, before running the command, ensure that Python is pre-installed on the computer. Most advanced versions of Mac OS distributions have Python pre-installed in it.

Following is the command typed in the Terminal:

**Mac OS Terminal code:**

```
python3 --version
```

**Output:**

```
Python 3.3.1
```

Alternatively, open the Terminal and type the below command:

**Mac OS terminal code:**

```
python --version
```

**Output:**

```
Python 2.7.4
```

The above command helps the user check whether python 2 is installed in the system.

Refer to the below screenshot for the results executed in the Mac OS terminal:

**Screenshot:**

[![Check the Python Version using Windows Command Line]()](https://www.guru99.com/images/3/check-python-version-23.webp)

## How to check Multiple python versions installed in the same system?

There can be multiple Python versions installed on the computer system. Therefore, a computer can have both versions 2 and 3 installed.

To validate both versions, the user can open the command line and type in the following commands:

### Scenario 1: To check Python version 2

**Command Line \\ Terminal code:**

```
python --version
```

### Scenario 2: To check Python version 3

**OS Command:**

```
python3 --version
```

## Python 2 or Python 3

Here are comparisons of both versions:

- Python version 3, compared to Python version 2 is different in terms of syntax. Here is a [complete comparison](https://www.guru99.com/python-2-vs-python-3.html) between the 2 versions.
- Python 3 contains a couple of utilities that help translate code written in Python 2 to Python 3.
- Python version 3 has a different syntax from Python version 2 because Python versions 2 and 3 have different syntaxes.
- Python 2 is not releasing any new updates, which makes this version incompatible with version 3.
- Some features of Python 3 were backported to Python 2, and this was done to support easy migration.
- Python 3 stores strings in Unicode format by default. However, to convert a string to Unicode format in version 2, it must be defined with the keyword “u”.

## FAQs

❓ How do open command lines in different Operating systems?

The coder can execute a single command to identify which version is installed in your computer’s operating system. You can do this by opening the command line of the operating system and typing below command as shown below:

- **Linux:** Ctrl + Alt + T or Ctrl + Alt + F2
- **Windows:** Win + R
- **Mac OS:** Finder > Applications > Utilities > Terminal

🏅 Perquisites for the system before Checking the Version

Here are important Perquisites for the system before checking the version:

- The user should access the command line.
- They should [install the latest version of Python](https://www.guru99.com/how-to-install-python.html) beforehand.
- It is also advisable to install any latest minor version of version 3 of Python. 1
- In order to validate the installed version, the user can open a command line after the installation. It is also called the Terminal in some operating systems, such as Linux and Mac OS.

📦 How do I check my pip version?

You can check pip, the Python package manager, by running pip –version or pip3 –version in the command line. This prints the pip version along with the Python version it is linked to.

🏷️ Why does the Python version matter?

The Python version determines which language features and libraries you can use. Python 2 and Python 3 have different syntax, and many packages support only specific versions, so checking the version prevents compatibility errors.

⬆️ How do I upgrade to a newer Python version?

Download the latest installer from python.org and run it, or use a version manager like pyenv. On Linux you can use the package manager. Always confirm the new version with python –version afterward.

🤖 Does the Python version matter for AI and machine learning libraries?

Yes. Libraries such as TensorFlow, PyTorch, and scikit-learn support only certain Python versions. Using a supported, recent Python 3 release avoids installation errors and ensures you get the latest performance and security updates.

🧠 Can AI help resolve Python version conflicts?

Yes. AI assistants can read error messages, identify version mismatches, and suggest the correct Python or package versions to install. They also help set up virtual environments so different projects can use different versions safely.

#### Summarize this post with:

ChatGPTPerplexityGrokGoogle AI

**Stay Updated on AI** **Get Weekly AI Skills, Trends, Actionable Advice.**

##### Sign up for the newsletter

Subscribe for Free

You have successfully subscribed.  
Please check your inbox.

![AI-Newsletter]() Chosen by over **350,000+** professionals

[Scroll to top](#wrapper)

×

Search for:

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://www.guru99.com/#organization","name":"Guru99","sameAs":["https://www.facebook.com/Guru99Official","https://twitter.com/guru99com"],"logo":{"@type":"ImageObject","@id":"https://www.guru99.com/#logo","url":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","contentUrl":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","caption":"Guru99","inLanguage":"en-US"}},{"@type":"WebSite","@id":"https://www.guru99.com/#website","url":"https://www.guru99.com","name":"Guru99","publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https://www.guru99.com/images/how-to-check-python-version.png","url":"https://www.guru99.com/images/how-to-check-python-version.png","width":"700","height":"250","caption":"How to Check Python Version","inLanguage":"en-US"},{"@type":"BreadcrumbList","@id":"https://www.guru99.com/check-python-version.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":"1","item":{"@id":"https://www.guru99.com","name":"Home"}},{"@type":"ListItem","position":"2","item":{"@id":"https://www.guru99.com/python","name":"Python"}},{"@type":"ListItem","position":"3","item":{"@id":"https://www.guru99.com/check-python-version.html","name":"How to Check Python Version on Linux, Mac &amp; Windows"}}]},{"@type":"WebPage","@id":"https://www.guru99.com/check-python-version.html#webpage","url":"https://www.guru99.com/check-python-version.html","name":"How to Check Python Version on Linux, Mac &amp; Windows","dateModified":"2026-10-07T13:01:12+05:30","isPartOf":{"@id":"https://www.guru99.com/#website"},"primaryImageOfPage":{"@id":"https://www.guru99.com/images/how-to-check-python-version.png"},"inLanguage":"en-US","breadcrumb":{"@id":"https://www.guru99.com/check-python-version.html#breadcrumb"}},{"@type":"Person","@id":"https://www.guru99.com/author/editorial","name":"Editorial Team","url":"https://www.guru99.com/author/editorial","image":{"@type":"ImageObject","@id":"https://www.guru99.com/images/favicon-new-logo.png","url":"https://www.guru99.com/images/favicon-new-logo.png","caption":"Editorial Team","inLanguage":"en-US"},"sameAs":["https://www.guru99.com/editorial-team"],"worksFor":{"@id":"https://www.guru99.com/#organization"}},{"articleSection":"Python","headline":"How to Check Python Version on Linux, Mac &amp; Windows","description":"Python scripts can identify the version of Python installed on the computer. It enables you to validate if multiple versions are installed in the system.","keywords":"python","speakable":{"@type":"SpeakableSpecification","cssSelector":[".entry-title",".summary"]},"@type":"Article","author":{"@id":"https://www.guru99.com/author/editorial","name":"Editorial Team"},"dateModified":"2026-10-07T13:01:12+05:30","image":{"@id":"https://www.guru99.com/images/how-to-check-python-version.png"},"copyrightYear":"2026","name":"How to Check Python Version on Linux, Mac &amp; Windows","subjectOf":[{"@type":"HowTo","name":"How to check the Python version using Windows Command Line?","description":"Here are steps to check the Python version using Windows Command Line:","step":[{"@type":"HowToStep","name":"Step 1) Open the command prompt","text":"And then type cmd","url":"https://www.guru99.com/check-python-version.html#step1"},{"@type":"HowToStep","name":"Step 2) When the command prompt opens","text":"Type the following command in the CLI to get the version name of Python.","url":"https://www.guru99.com/check-python-version.html#step2"}]},{"@type":"FAQPage","mainEntity":[{"@type":"Question","name":"How do you open command lines in different Operating systems?","acceptedAnswer":{"@type":"Answer","text":"Open the command line per OS: on Linux use Ctrl + Alt + T or Ctrl + Alt + F2, on Windows press Win + R, and on Mac go to Finder &gt; Applications &gt; Utilities &gt; Terminal. Then type the version command."}},{"@type":"Question","name":"What are the prerequisites before checking the Python version?","acceptedAnswer":{"@type":"Answer","text":"Before checking, you should be able to open the command line, have Python installed, and preferably a recent minor release of Python 3. The command line is called the Terminal on Linux and Mac operating systems."}},{"@type":"Question","name":"How do I check my pip version?","acceptedAnswer":{"@type":"Answer","text":"You can check pip, the Python package manager, by running pip --version or pip3 --version in the command line. This prints the pip version along with the Python version it is linked to."}},{"@type":"Question","name":"Why does the Python version matter?","acceptedAnswer":{"@type":"Answer","text":"The Python version determines which language features and libraries you can use. Python 2 and Python 3 have different syntax, and many packages support only specific versions, so checking the version prevents compatibility errors."}},{"@type":"Question","name":"How do I upgrade to a newer Python version?","acceptedAnswer":{"@type":"Answer","text":"Download the latest installer from python.org and run it, or use a version manager like pyenv. On Linux you can use the package manager. Always confirm the new version with python --version afterward."}},{"@type":"Question","name":"Does the Python version matter for AI and machine learning libraries?","acceptedAnswer":{"@type":"Answer","text":"Yes. Libraries such as TensorFlow, PyTorch, and scikit-learn support only certain Python versions. Using a supported, recent Python 3 release avoids installation errors and ensures you get the latest performance and security updates."}},{"@type":"Question","name":"Can AI help resolve Python version conflicts?","acceptedAnswer":{"@type":"Answer","text":"Yes. AI assistants can read error messages, identify version mismatches, and suggest the correct Python or package versions to install. They also help set up virtual environments so different projects can use different versions safely."}}]}],"@id":"https://www.guru99.com/check-python-version.html#schema-221943","isPartOf":{"@id":"https://www.guru99.com/check-python-version.html#webpage"},"publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US","mainEntityOfPage":{"@id":"https://www.guru99.com/check-python-version.html#webpage"}}]}
```
