Python code to check if Raspberry OS are Running in 32-bit or 64-bit
Python sys.maxsize is an integer giving the maximum value a variable of type Py_ssize_t can take. It’s usually 2**31 - 1 on a 32-bit platform and 2**63 - 1 on a 64-bit platform. Using it, Python code can check if running OS is 32-bit or 64-bit.
import sys
import os
print(os.uname())
print(os.uname()[1], os.uname()[4])
print("Is it 64 bit?", sys.maxsize > 2**32)
Run on Raspberry Pi 5/64-bit Raspberry Pi OS (bookworm):
Run on Raspberry Pi 4B/32-bit Raspberry Pi OS (bookworm):
Comments
Post a Comment