The Wayback Machine - https://web.archive.org/web/20240822101521/https://www.geeksforgeeks.org/check-the-version-of-the-python-interpreter/
Open In App

How to check Python Version : Windows, Linux and Mac

Last Updated : 09 Aug, 2024
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

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
Checking python version in Linux

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 Linux

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
Checking python version in Linux

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.

checking with path

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


Similar Reads

How to Install Requests in Python - For Windows, Linux, Mac
Requests is an elegant and simple HTTP library for Python, built for human beings. One of the most famous libraries for Python is used by developers al over the world. This article revolves around how one can install requests library of Python in Windows/ Linux/ macOS using pip. Install Requests Module in Python in Window For installing requests in
4 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 windows, there is no universal library for installing Py
2 min read
How to Download and Install Python Latest Version on Linux?
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 Linux Operating Systems. On every Linux system including following OS, Ubuntu Linux Mint Debian openSUSE CentOS Fedora and my favourite one, Arch Linux. You will find Python
3 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, we'll explore different methods to check your OpenC
3 min read
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 interface and comprehensive data access, yFinance is
2 min read
Check Version of Installed Python Modules
In Python, managing packages is an essential part of the development process. Knowing the version of the package that is currently installed can help us to ensure compatibility and debug issues effectively in our python code. In this article, we will explore methods to determine the version of packages installed in our current working python enviro
2 min read
How to install Python and PyCharm on Mac
Installing PyCharm on macOS is a straightforward process. PyCharm is a popular Integrated Development Environment (IDE) for Python programming, and it offers both a free community edition and a more feature-rich professional edition. In this article, I will guide you through the steps to install PyCharm on your macOS. MacOS Installation on PyCharmS
2 min read
How to check Django version
This article is for checking the version of Django. When we create projects using Django and sometimes we might stuck where the version is not able to support certain functions of your code. There are many methods to check the current version of Django but you need Django installed on your machine. Check Django Version using the TerminalExample 1:
2 min read
How to check NumPy version installed?
In this article, we are going to learn how we can find out which version of NumPy your Python code uses. The version of any project keeps on changing with time as the project gets updated, new features keep being added, and old bugs are removed. Hence, a lot of work keeps on happening on projects especially one like NumPy which is a very popular Py
2 min read
How to Check PySpark Version
Knowing the version of PySpark you're working with is crucial for compatibility and troubleshooting purposes. In this article, we will walk through the steps to check the PySpark version in the environment. What is PySpark?PySpark is the Python API for Apache Spark, a powerful distributed computing system that allows for large-scale data processing
3 min read
How to Check PyYAML Version
Python Programming Language has various libraries and packages for making tasks easier and more efficient. One such library is PyYAML, which is widely used for parsing and writing YAML, a human-readable data serialization standard. In this article, we will see different methods to check the PyYAML version installed on our system. What is PyYAML?PyY
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 and tools which are written in Python. Pip allows
5 min read
Extracting MAC address using Python
MAC address also known as physical address is the unique identifier that is assigned to the NIC (Network Interface Card) of the computer. NIC helps in connection of a computer with other computers in the network. MAC address is unique for all the NIC's. Uses of MAC address : Useful in places where IP address change frequently. Helps network admin.
3 min read
Python script to get device vendor name from MAC Address
Prerequisite: Python Requests A MAC address is a unique identity of a network interface that is used to address the device in a Computer Network. What does MAC Address consist of? A MAC address is made up of 12 hexadecimal digits, 6 octets separated by ':'. There are 6 octets in a MAC address. In the first half, the manufacturer info is stored. How
2 min read
How to download and install Python Latest Version on Android
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 Android. Python can run on Android through various apps from the play store library. This tutorial will explain how to run python on Android using Pydroid 3 - IDE for Python
2 min read
How to Download Python Old Version and Install
Python is a popular programming language known for its simplicity and versatility. When we install Python in our systems we always install the latest version of it but there may be situations where we need to install an older version of Python due to compatibility reasons or to work on legacy projects so that we can use old features of Python that
2 min read
Download and Install Python 3 Latest Version
To understand how to Download Python and Install Python You need to know What Python is and where it is actually installed in your system. Let's consider a few points: Python is a widely used general-purpose, high-level programming language. Every Release of Python is open-source. Python releases have also been General Public License (GPL) -compati
4 min read
Creating Python Virtual Environment in Windows and Linux
A Virtual Environment is a Python environment, that is an isolated working copy of Python that allows you to work on a specific project without affecting other projects So basically it is a tool that enables multiple side-by-side installations of Python, one for each project. Creating a Python virtual environment in Linux If pip is not in your syst
2 min read
Python - Install Paramiko on Windows and Linux
The high-level python API starts with the creation of a secure connection object. To have more direct control and pass a socket to transport to start remote access. As a client, it's authenticating using a user credential or private key, and checking the server’s host key. Paramiko is a Python library that makes a connection with a remote device th
1 min read
rangev2 - A new version of Python range class
range() is a built-in function of Python. It is used when a user needs to perform an action for a specific number of times. The range() function is used to generate a sequence of numbers. But the sequence of numbers produced by range is generally either decreasing or increasing linearly which means it is either incremented and decremented by a part
2 min read
Get Application Version using Python
Software versioning maybe thanks to reasoning the distinctive states of pc software package because it is developed and discharged. The version symbol is typically a word, a number, or both. For instance, version 1.0 is often accustomed to denote the initial unharness of a program. In this article, we will see how to get an application version numb
2 min read
Install Python Latest Version on MacOS
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's latest version on Mac OS. Like Linux, macOS also comes with Python pre-installed on the system. To update to the latest version, we will use the Homebrew Package Manager. It is one of the b
2 min read
Python Version History
Python, one of the most popular programming languages today, has a rich history of development and evolution. From its inception in the late 1980s to its current status as a versatile and powerful language, Python's version history reflects the language's adaptability and the community's dedication to improvement. This article explores the signific
5 min read
How to Fix AttributeError: Module 'distutils' has no attribute 'version' in Python
The error message "Module 'distutils' has no attribute 'version'" typically occurs when there is a conflict or issue with the installed version of the Python or distutils module. This error can be frustrating but fortunately there are several steps we can take to the troubleshoot and resolve it. In this article, we'll explore the possible causes of
3 min read
Integrating Poetry in Python with version control systems
Version control systems, like Git, are crucial components in today’s software application development processes. They assist in controlling modification to the project's source code, working with other developers, and, reviewing the history of the project. In this tutorial, crucial steps of Poetry’s integration with the project’s version control ar
7 min read
Update Jupyter Notebook to the Latest Python Version
To take advantage of the latest features and improvements in Python, it is important to keep your Jupyter Notebook updated with the latest Python version. This article will guide you through the process of updating Jupyter Notebook to the latest Python version. Note: Let's say if we want to Download Install from Python 3.7 to 3.11: Checking the Cur
3 min read
Download and install pip Latest Version
PIP is a package management system used to install and manage software packages/libraries written in Python. These files are stored in a large “on-line repository” termed as Python Package Index (PyPI). After you have successfully installed Python, you would clearly need pip in order to install packages, such as Numpy, Django and lots more on your
2 min read
Find the version of the Pandas and its dependencies
Pandas is one of the most important packages for data analysis in Python and that means frequent updates of the version of the Pandas. This leads to compatibility issues with other dependencies of Pandas. Let's discuss the ways to check the version of the Pandas and its dependencies running on any system.  Find the Version of the Pandas Running on
3 min read
How to Install SQLObject package on Windows and Linux?
An object-relational mapping is a bridge between the two worlds. SQLObject is a popular Object Relational Manager for provide an object interface to database, with tables as classes, rows as instances, and columns as attributes. Using an object-relational mapping doesn’t mean that you don’t need to know how relational databases work, but it does sa
2 min read
PyQt5 QSpinBox - Getting translated version of text
In this article we will see how we can get the translated version of the text. Translated version of text is based on the disambiguation string and value of n for strings containing plurals. If no appropriate translated string is available translated text will be a UTF-8 string i.e a Unicode codec and can represent all characters in a Unicode strin
2 min read
Practice Tags :
three90RightbarBannerImg