"
This article is part of in the series

In 2019, The Python Software Foundation announced a change in the release calendar, making it so a new version of the language is released every 12 months.

The organization also announced that every Python version would receive bug-fix updates for a year and a half and security updates for three and a half years before bringing the version to its end-of-life at the end of the five years.

Using the latest version of Python is the best way to ensure you get a bug-free and secure experience. 

But how do you check the python version?

It’s a lot easier than you think – but you must first ensure that you have Python installed on your computer. If you haven’t installed Python yet, our easy installation guide will help you set it up in minutes.

If Python is installed on your computer, here’s how you can find the version quickly.

How to Check Python Version in Linux, Mac, & Windows

Python ranked fourth in popularity in the Stack Overflow 2020 Developer Survey. The survey was taken by 65,000 developers across the globe, making it a reliable depiction of developer and business preference of programming language use.

Before you can check what version of Python your computer has loaded, you must understand the version scheme of Python. Every Python version has three digits.

The first digit represents the major version, the second the minor version, and the third digit represents the micro version or “revision level.”

You must also note that major versions are typically not fully compatible with each other. In other words, software written with Python version 2.x.x may not run correctly with Python 3.x.x.

However, minor releases are typically compatible with the previous releases. For example, code written in Python 3.1.x will run with Python 3.9.x (which is the current Python version).

Checking Python Version in Linux

Most modern Linux distributions come with Python pre-installed. You don’t have to type in any lines of code to install it yourself – unless you’re using a relatively less popular Linux distro. 

Checking the Python version on a Linux machine is simple. The first step is to open up the Terminal. If you’re using a distribution like Ubuntu, you can go to the menu and search for it.

However, the easiest way to open the Terminal is to press Ctrl+Alt+T. Alternatively, you can press the Ctrl, Alt, and F2 keys together.

A terminal window will appear on your screen. You can then enter the following command:

        python ––version

or alternatively:

        python -V

Your machine can have multiple versions of Python installed. If your machine has Python 3 installed, entering either of the following commands in the Terminal will also do the trick:

        python3 –version

or

        python3 -V

After entering the command in the Terminal, press the Enter key. The Python version will appear on the next line, like so:

You can run this command on any hardware that’s running a Linux OS – including a Raspberry Pi.

Checking Python Version in Mac

There is no PowerShell or Command Prompt on macOS. However, the operating system has a terminal like Linux and Unix systems do. You will need to access the Terminal to check the Python version on your Mac.

To open the Terminal, open the Finder. Then navigate to Applications, and select Utilities. Find and launch the Terminal from here.

The instructions from here are similar to the instructions for Windows systems. To find the Python version, you have to enter the following command:

        python --version

If Python 3 is installed on your computer, too, you can find the exact version of Python 3 you’re using by entering the following command:

        python3 –version

The details of the Python version will appear on the next line, like so:

Checking Python Version in Windows

If you’re using Windows 10, you can find the Python version using Windows PowerShell. The simplest way of launching PowerShell is to hit the Windows key and type “powershell.” You can then select it from the list of options that appears.

All you have to do next is type the following:

        python --version

The details will appear on the next line.

Checking Python Version with A Program

It is possible for you to open the Python interpreter on your Terminal and write a few lines of code to determine the Python version.

To run the Python interpreter on your computer:

  • On Windows: Launch PowerShell and type “python” into the Terminal.
  • On macOS: Navigate to Applications > Utilities > Terminal and type “python.” If you have Python 3 installed, type “python3.”
  • On Linux: Open up the Terminal and type “python” or “python3,” depending on what you have installed on the machine.

If you see “>>>” appear on the Terminal, Python is in interactive mode. Next, you must copy-paste the following lines of code into the interpreter:

        import sys

        print("User Current Version:-", sys.version)

The details of the Python version installed will appear in the output. 

To exit the interpreter, you can either type in “quit()” or “exit(),” both of which are built-in Python functions.

Alternatively, if you’re on Windows, you can press Shift+Ctrl+Z and Enter. On Unix-like systems, pressing Shift+Ctrl+D should stop the interpreter.

Conclusion

Every version of Python – even the newest release – has its own limitations. However, keeping Python updated will improve security and make the experience less error-ridden.

Updating to the newest version also ensures that you can use the latest features, syntax, and library modules Python has to offer.

Now that you know how to find the version of Python installed on your computer, you can learn if you’re up to date in instants.