×

How to check version of Python

How to check version of python

The versions of Python come with different kinds of features and functionalities. It is not a herculean task to keep track of the updates these days. Just some simple pre-requisites and you are on the path of consistent learning in Python. Python is compatible on all platforms and we can execute its programs on different operating systems. Here we will be looking at some ways & means and how they provide us a medium to check the version of Python installed on our PCs.

So, let’s get started….

It works on the concept of semantic versioning (MAJOR.MINOR. MICRO). Let’s have a look at what do they indicate-

Major – Major versions are the ones in which incompatible API changes are done.

Minor – Minor versions are the ones in which any functionality is added.

Micro – Micro versions are the ones in which bug fixes and updates related to improvements are done.

For instance, the version of Python installed in my system is Python 3.7.3

Here,

  • 3 is the major version.
  • 7 is the minor version.
  • 3 is the micro version.

As we discussed earlier, python can work smoothly on different operating systems. So, let's have a glance at how we can check the versions of python on-

  1. Windows
  2. Linux
  3. MacOS
  4. Using Scripting

How to check the version of Python in Windows?

There are two ways to check the version of Python in Windows-

  • Using Powershell
  • Using Command Prompt

Using Powershell

check version of Python
  1. Click ‘Win+R’ or type ‘Run’ on the taskbar’s search pane.
  2. Type ‘Powershell’
  3. A window will appear on your screen named ‘Windows Powershell’
  4. Click on ‘Enter’
  5. Type python –version and click on ‘Enter’
  6. The version would be displayed in the next line.

Using Command Prompt

check version of Python

Type 'Command Prompt' on the taskbar's search pane and you'll see its icon. Click on it to open the command prompt.

Also, you can directly click on its icon if it is pinned on the taskbar.

  1. Once the ‘Command Prompt’ screen is visible on your screen.
  2. Type python –version and click on ‘Enter’.
  3. The version installed in your system would be displayed in the next line.

How to check the version of Python in Linux?

Linux is a free and open-source operating system. The users have access and authority to run, modify & distribute the source code. The command line present in Linux is the medium through which we can interact with our system. It consists of a kernel, system user space, and applications.

In Linux, we have a shell where we type our commands that are interpreted and tells the operating system about what the user wants.

The steps to check the version of Python in Linux is-

  • Start your system and switch on to the Linux operating system (you might find it with the name Ubuntu).
  • Once the desktop screen of Linux appears, click on ‘Terminal’ to open it.
  • In the terminal window, type python –version and click on ‘Enter’.
  • In the next line, it will display the current version of python installed in your system.         

How to check the version of Python in MacOS?

MacOS is a popular operating system developed by Apple Inc. Its dynamic features and latest updates have made it prevalent among professionals and students.

The steps to check the version of Python in MacOS are-

  1. Open ‘Terminal’ in MacOS.
  2. Type python –version
  3. It will display the current version of python installed in your system.           

How to check the version of Python using scripting?

We can check the version of python also by using scripting. The piece of code given below will help you to know the version you are currently working on. Let’s understand the variables that are used here-

  1. sys.version_info.major
  2. sys.version_info_minor

Both of them are a part of the tuple that returns the version number. In general, sys.version_info has five components namely major, minor, micro, release levels, and serial

We can execute the given code-

            import sys
            print(sys.version)
           print(sys.version_info)   #it will display the value of five components
          print(sys.version_info.major)
 print(sys.version_info.minor) 

So, these were the four different approaches we discussed to check the version of Python.

Now we have a clear idea of how to proceed with the checking process on Windows, Linux, MacOS, and through scripting.


Related Topics

Cross Validation in Sklearn

Data scientists can benefit from cross-validation in machine learning in two key ways: it can assist in minimising the amount of data needed and ensure the artificial intelligence model is...

14 minutes read.

Check Letter in a String Python

Checking a specific letter or a character in a given string or a string which is taken as an input from the user is possible in Python in broadly three...

3 minutes read.

How to get Time in seconds in Python

Python's time module source shows that are based on time. The time() method is used by developers and returns the current time as a UNIX timestamp. A UNIX timestamp is...

4 minutes read.

How to create a DataFrames in Python

How to create a DataFrames in Python Data Frame is a data structure in which data is stored in tabular form. They can also be referred as two-dimensional collection of data. Various...

5 minutes read.

Python Tricks: The Book

A Buffet of Awesome Python Features Dan Bader is the author of the book called Python Tricks . he is the owner and editor of Real Python and one of the...

3 minutes read.

Write a String in Python

Python is an object-oriented high-level programming language. Python has dynamic semantics and has high-level built-in data structures which support dynamic typing and dynamic binding. Python provides rapid development. It has...

5 minutes read.

Python Comments

In this tutorial, we will discuss the importance of comments in the Python code and how various types of comments can be inserted in the code. Comments are used to describe...

3 minutes read.

N2 in Python

N2 is known as Nearest Neighbor Algorithm, because it contains 2 N's (N-Nearest, N-Neighbor). This is a library in the python build using C++ and Python. Before N2 was made,...

3 minutes read.

CatPlot in Python

Python Seaborn Library Seaborn is a superb Python tool for displaying graphical statistics graphing. Seaborn provides different color schemes and attractive default styles to facilitate the creation of various statistics charts...

8 minutes read.

Python MongoDB Tutorial

An Introduction to MongoDB MongoDB is a document-oriented database application. It is an Open-source and platform-independent program. MongoDB is similar to few NoSQL databases that store the data in the documents...

17 minutes read.

Python lock

Before understanding the concept of Python-lock we need to understand what kind if condition we require to implement the locks in Python. Let us start with multithreading and its implementation...

5 minutes read.

How to check version of Python

How to check version of python The versions of Python come with different kinds of features and functionalities. It is not a herculean task to keep track of the updates these...

3 minutes read.

Python and its advantages

What is Python? Python is an object-oriented programming language, a general-purpose programming language with a high level, and also an interpreted language that has an easy syntax and dynamic semantics. Python...

7 minutes read.

Python MySQL Database Connection

In this article, you will be able to understand how to connect to a MySQL database through Python. We generally can use many methods or modules to connect to the database...

6 minutes read.

Python any() Function

Python any() Function The any() function in Python returns a boolean value ‘True’ if any element of the iterable is true or if the iterable is empty, else it returns False. Syntax any(iterable) Parameter Iterable: An iterable object (list, tuple, dictionary) Return This...

1 minute read.

Python program to find the area of the triangle

Python program to find the area of the triangle This article will discuss how to find the area of a triangle in Python with all three given sides. The area of...

2 minutes read.

Front end in python

Python : Python is an object oriented programming language which is highly interpreted and is highly interactive. Python was created by Guido van Rossum in the year 1985 – 1990 .The...

4 minutes read.

Python Program to find the length of a string

Python program to find the length of a string A string in Python is a set of Unicode characters. It can't be changed once it's been declared. The number of characters...

2 minutes read.

Write Text files in Python

Let's discuss writing the text file in detail. Generally, writing text also follows the same procedure as like reading text. It varies only in some specific places. Steps followed for writing...

4 minutes read.

Python String endswith() method

Python String endswith() method The string.endswith() method in Python returns a Boolean value True if the string ends with the specified suffix, otherwise it returns False. Syntax endswith(suffix[, start[, end]]) Parameter suffix – This parameter represents a string or tuple...

2 minutes read.