Platform Module in Python
Last Updated :
02 Jun, 2025
Platform module in Python is a built-in library that provides a portable way to access detailed information about the underlying platform (hardware and operating system) on which your Python program is running. This can include data such as the OS name and version, machine type, processor info and Python runtime details. Understanding the platform your code is running on is useful for:
- Ensuring compatibility with certain Python versions or system architectures.
- Tailoring functionality based on operating system specifics.
- Gathering system diagnostics or environment info for debugging or deployment.
Since it’s part of Python’s standard library, no additional installation is required. You simply import it:
import platform
Platform functions
These functions provide information about the operating system, processor, node and general system details. They're useful when writing code that needs to behave differently depending on the environment.
1. platform.processor(): Returns the processor name or identifier of your system. Helpful when you want to know what CPU the program is running on.
Python
import platform
print(platform.processor())
Output
Intel64 Family 6 Model 154 Stepping 4, GenuineIntel
2. platform.architecture(): Tells whether your Python is running in 32-bit or 64-bit mode. Useful for compatibility checks.
Python
import platform
print(platform.architecture())
Output
('64bit', 'WindowsPE')
3. platform.machine(): Returns the machine type (e.g., ‘x86_64’, ‘AMD64’, etc.). It's handy for identifying the hardware architecture.
Python
import platform
print(platform.machine())
Output
AMD64
4. platform.node(): Gives the network name (hostname) of the computer. Good for identifying the device in networks.
Python
import platform
print(platform.node())
Output
GFG0578-VISHAKSHI
5. platform.platform(): Returns a single string describing the platform (OS name and version). Great for logging system info.
Python
import platform
print(platform.platform())
Output
Windows-10-10.0.26100-SP0
6. platform.system(): Returns the name of the operating system. It’s commonly used for OS-based decisions in scripts.
Python
import platform
print(platform.system())
Output
Windows
7. platform.uname(): Returns a named tuple with detailed system information: system, node, release, version, machine. More detailed than other functions.
Python
import platform
uname = platform.uname()
print(uname)
Output
uname_result(system='Windows', node='GFG0578-VISHAKSHI', release='10', version='10.0.26100', machine='AMD64')
These functions give details about the currently running Python interpreter, its version, build, compiler and implementation. Useful when ensuring compatibility or diagnosing environment issues.
1. platform.python_version(): Returns the Python version as a string. Useful for ensuring compatibility with your code.
Python
import platform
print(platform.python_version())
Output
3.11.9
2. platform.python_build(): Shows when and how the Python interpreter was built. Useful for debugging or understanding build history.
Python
import platform
print(platform.python_build())
Output
('tags/v3.11.9:de54cf5', 'Apr 2 2024 10:12:12')
3. platform.python_compiler(): Tells which compiler was used to build Python (e.g., MSC for Windows). Helpful for advanced debugging.
Python
import platform
print(platform.python_compiler())
Output
MSC v.1938 64 bit (AMD64)
4. platform.python_implementation(): Returns the Python implementation in use like CPython, PyPy, or Jython.
Python
import platform
print(platform.python_implementation())
Output
CPython
5. platform.python_branch(): Shows the branch from which Python was built. Mostly relevant for developers working with Python source.
Python
import platform
print(platform.python_branch())
Output
tags/v3.11.9
OS specific functions
These platform-specific methods provide details relevant to particular operating systems. They're useful for tailoring behavior to macOS, Windows, or Linux environments.
1. For macOs: platform.mac_ver() gives macOS version details. Only relevant when running the script on a Mac.
Python
print(platform.mac_ver())
Output
('10.15.7', ('', '', ''), 'x86_64')
2. For unix/Linux: platform.libc_ver() returns the version of the C library (glibc) used by the OS. Useful for deep Linux debugging.
Python
print(platform.libc_ver())
Output
('glibc', '2.31')
3. For windows: platform.win32_ver() gives detailed Windows version info. Use it to fine-tune compatibility on different Windows editions.
Python
print(platform.win32_ver())
Output
('10', '10.0.19041', 'SP0', 'Multiprocessor Free')
Related Articles
Similar Reads
Python Module Index Python has a vast ecosystem of modules and packages. These modules enable developers to perform a wide range of tasks without taking the headache of creating a custom module for them to perform a particular task. Whether we have to perform data analysis, set up a web server, or automate tasks, there
4 min read
Python | platform.uname() Method In this article, we will learn how to detect the operating system that is currently being used in your system using Python. Detect OS Using the platform Module in Python The platform.uname() method in python is used to get information about the current operating system. This method returns informati
1 min read
Python Introduction Python was created by Guido van Rossum in 1991 and further developed by the Python Software Foundation. It was designed with focus on code readability and its syntax allows us to express concepts in fewer lines of code.Key Features of PythonPythonâs simple and readable syntax makes it beginner-frien
3 min read
External Modules in Python Python is one of the most popular programming languages because of its vast collection of modules which make the work of developers easy and save time from writing the code for a particular task for their program. Python provides various types of modules which include built-in modules and external m
5 min read
Built-in Modules in Python Python is one of the most popular programming languages because of its vast collection of modules which make the work of developers easy and save time from writing the code for a particular task for their program. Python provides various types of modules which include Python built-in modules and ext
9 min read
Learn Python Basics âPython is a versatile, high-level programming language known for its readability and simplicity. Whether you're a beginner or an experienced developer, Python offers a wide range of functionalities that make it a popular choice in various domains such as web development, data science, artificial in
9 min read
Introduction to Python3 Python is a high-level general-purpose programming language. Python programs generally are smaller than other programming languages like Java. Programmers have to type relatively less and indentation requirements of the language make them readable all the time. Note: For more information, refer to P
3 min read
Why is Python So Popular? One question always comes into people's minds Why Python is so popular? As we know Python, the high-level, versatile programming language, has witnessed an unprecedented surge in popularity over the years. From web development to data science and artificial intelligence, Python has become the go-to
7 min read
Why Python is Called a Cross-Platform Language Python, a high-level, interpreted programming language, is renowned for its cross-platform capabilities. This attribute signifies that Python code can run on various operating systemsâsuch as Windows, macOS, Linux, and othersâwithout requiring substantial modifications. Why Python is Called a Cross-
4 min read
Python - Get Hardware and System information using platform module In this article, we will see how we can show information about our system i.e processor name, name of system etc. The Platform module is used to retrieve as much possible information about the platform on which the program is being currently executed. Now by platform info, it means information about
2 min read