Python is a versatile and powerful programming language, highly appreciated by developers all over the world. One of the things you might occasionally need to check is whether the Python interpreter installed on your Linux system is a 32-bit or a 64-bit.
It’s essential to know this because it determines what kind of applications you can run and how efficiently your system can execute those programs.
Check the Python architecture using the platform module
The simplest way to check the bit version of Python installed is by using the platform module within the Python interpreter.
1 2 |
import platform print(platform.architecture()) |
For example, the output for a 64-bit Python would look something like this:
1 |
('64bit', 'WindowsPE') |
Check Python architecture using the sys module
Another method to check the Python version is by using the sys module within the Python interpreter.
1 2 |
import sys sys.maxsize > 2**32 |
The output for a 64-bit Python would be:
1 |
True |
Conclusion
In conclusion, Python provides multiple ways of determining the kind of architecture your Python interpreter features. It’s a trivial task, yet crucial in certain application development scenarios that require leveraging the capabilities of 64-bit address spaces.
By merely utilizing some built-in Python modules like platform and sys, you can efficiently and swiftly determine the version of your Python interpreter.