Get CPU info with pure Python
Maintained. Last release 8 months ago, commits in 0 of the last 26 weeks. Weaker on commit activity.
$
pip install py-cpuinfo2py-cpuinfo2
This is a friendly drop-in fork of py-cpuinfo.
Py-cpuinfo gets CPU info with pure Python. Py-cpuinfo should work without any extra programs or libraries, beyond what your OS provides. It does not require any compilation(C/C++, assembly, et cetera) to use. It works with Python 3.
Example
if __name__ == '__main__':
from cpuinfo import get_cpu_info
for key, value in get_cpu_info().items():
print("{0}: {1}".format(key, value))
API
'''
Returns the CPU info by using the best sources of information for your OS.
Returns the result in a dict
'''
get_cpu_info()
'''
Returns the CPU info by using the best sources of information for your OS.
Returns the result in a json string
'''
get_cpu_info_json()
Fields
| key | Example value | Return Format |
|---|---|---|
| "python_version" | "3.10.4.final.0 (64 bit)" | string |
| "cpuinfo_version" | (8, 0, 0) | (int, int, int) |
| "cpuinfo_version_string" | "8.0.0" | string |
| "hz_advertised_friendly" | "2.9300 GHz" | string |
| "hz_actual_friendly" | "1.7330 GHz" | string |
| "hz_advertised" | (2930000000, 0) | (int, int) |
| "hz_actual" |