Getting Platform System Information Using Python

Hi there, today we will be talking about something which is very interesting as well as simple: Getting platform information using Python. A few lines of code can be used to get all the information.

So let’s get started right away.

Getting System Information using Python

Requirements:  

Basic knowledge of python(Learn Python Tutorial) . We can use any ide ( for example: https://code.visualstudio.com/download, https://jupyter.org/) .

Modules required:

Platform:  Platform is an in-built module in Python. It is used to get any kind of information about the system or platform on which we are executing the program, currently. Not only the system information ,but it is also helpful to fetch information about our Python software running on the system.

Installation:  

It comes with python installation, therefore we don’t need to install it.

Approach for System Information:  

1. Firstly, we have to import the platform module.

import platform

2. Most importantly, to get information about our system we have to know the platform functions well. Let’s have a look of them:

A. platform.system() – displays the name of the operating system(for example – windows,linux).

B. platform.version() – displays the version of the operating system.

C. platform.release() – returns the OS Release.

D. platform.machine() – helps to know the machine type.

E. platform.processor() – displays the name of the processor.

F. platform.node() – returns the network name.

G. platform.platform() – allow us to know many useful information that is to retrievable about the system .

Source Code:

import platform 
print("My Operating System : ",platform.system())
print("My OS Version: ",platform.version())
print("OS Release: ",platform.release())
print("My Machine Type: ",platform.machine())
print("My System's Processor: ",platform.processor())
print(“My Network Name: ",platform.node())
print("Useful Information Of My Platform : ",platform.platform())

Output:

My Operating System :  Windows
My OS Version:  10.0.19041
OS Release:  10
My Machine Type:  AMD64
My System's Processor:  AMD64 Family 23 Model 24 Stepping 1, AuthenticAMD
My Network Name:  LAPTOP-FOUE02LK
Useful Information Of My Platform :  Windows-10-10.0.19041-SP0
System Information Using Python

Getting Python Software Information:  

Approach:

1. Firstly, we have to import the platform module.

 import platform

2. Further, we will see some of the useful platform functions .

A. platform.python_version() – displays the version of the python software(for example – 3.4.10 , 3.7.10).

B. platform.python_version_tuple() – displays the version of the python software in tuple.

C. platform.python_build() – returns the build info of the python software.

D. platform.python_compiler() – helps to know about the compiler.

E. platform.python_implementation() – returns python implementation(for example- CPython, PyPy, Jython ) .

Source Code:

import platform 
print("My Python version is : ",platform.python_version())
print("My Python version in tuple: ",platform.python_version_tuple())
print("Build info of my Python software: ",platform.python_build())
print("Compiler info of my Python Software: ",platform.python_compiler())
print("Implementation: ",platform.python_implementation())

Output:

My Python version is :  3.9.0
My Python version in tuple:  ('3', '9', '0')
Build info of my Python software:  ('tags/v3.9.0:9cf6752', 'Oct  5 2020 15:34:40')
Compiler info of my Python Software:  MSC v.1927 64 bit (AMD64)
Implementation:  CPython
Python Software Information Using Python