{"id":926,"library":"py-cpuinfo","title":"py-cpuinfo","description":"Py-cpuinfo is a pure Python library designed to retrieve detailed CPU information across various operating systems, including Linux, macOS, Windows, BSD, Solaris, Cygwin, Haiku, and BeagleBone. It functions without requiring any external programs or compilation beyond the standard OS provisions. The library is compatible with Python 3. The current stable version is 9.0.0, released in October 2022.","status":"active","version":"9.0.0","language":"python","source_language":"en","source_url":"https://github.com/workhorsy/py-cpuinfo","tags":["system","cpu","hardware","info","utility"],"install":[{"cmd":"pip install py-cpuinfo","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"get_cpu_info","correct":"from cpuinfo import get_cpu_info"}],"quickstart":{"code":"from cpuinfo import get_cpu_info\n\ninfo = get_cpu_info()\nfor key, value in info.items():\n    print(f\"{key}: {value}\")","lang":"python","description":"This example demonstrates how to retrieve and print all available CPU information using the `get_cpu_info()` function."},"warnings":[{"fix":"Add `multiprocessing.freeze_support()` at the very beginning of your main script (before any other code) or ensure it's called if your freezing tool has a specific entry point for multiprocessing initialization. Refer to the `py-cpuinfo` GitHub issues or `multiprocessing` documentation for detailed integration with freezing tools.","message":"When compiling applications using PyInstaller or Cx_Freeze that incorporate `py-cpuinfo`, the frozen executable may exhibit high CPU usage or create multiple processes, potentially leading to crashes. This is a common issue with libraries that use multiprocessing.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always prefer the parsed and standardized fields provided by `get_cpu_info()` for reliable data. Use 'Raw Fields' with extreme caution and implement robust validation if absolutely necessary.","message":"The `py-cpuinfo` library provides 'Raw Fields' which are direct outputs from underlying system calls or CPUID registers. These values are unverified and may contain unexpected, incorrect, or even garbage data. Relying on these raw fields directly can lead to inaccurate information.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Be aware that these specific frequency fields might not always be accurate. If precise clock speed measurement is critical, consider cross-referencing with other system tools or exploring alternative hardware-specific methods outside of this library.","message":"On some systems, the `hz_actual` and `hz_advertised` fields returned by `get_cpu_info()` may incorrectly report a static low frequency (e.g., 400MHz) instead of the CPU's actual or advertised maximum clock rates. This can lead to misleading performance metrics.","severity":"gotcha","affected_versions":"All versions, especially on specific hardware/OS configurations."}],"env_vars":null,"search_vec":"'2022':62 '3':52 '9.0.0':58 'across':18 'beaglebon':31 'beyond':41 'bsd':26 'compat':49 'compil':40 'cpu':16,64 'cpuinfo':3,6 'current':54 'cygwin':28 'design':12 'detail':15 'extern':37 'function':33 'haiku':29 'hardwar':65 'includ':22 'info':66 'inform':17 'librari':11,47 'linux':23 'maco':24 'octob':61 'oper':20 'os':44 'program':38 'provis':45 'pure':9 'py':2,5 'py-cpuinfo':1,4 'python':10,51 'releas':59 'requir':35 'retriev':14 'solari':27 'stabl':55 'standard':43 'system':21,63 'util':67 'various':19 'version':56 'window':25 'without':34","created_at":"2026-03-29T06:08:00.486813+00:00","updated_at":"2026-04-16T18:16:42.782984+00:00","problems":[{"fix":"The correct way to import the library after installing `py-cpuinfo` is `import cpuinfo`.","cause":"The Python package is installed as `py-cpuinfo`, but developers often mistakenly try to import it using `import py-cpuinfo` or when it's not correctly bundled with freezing tools like PyInstaller.","error":"ModuleNotFoundError: No module named 'cpuinfo'"},{"fix":"Safely access the dictionary key using the `.get()` method, for example: `cpuinfo.get_cpu_info().get('brand')`, which will return `None` if the key is not found instead of raising a KeyError.","cause":"The `get_cpu_info()` function returns a dictionary, and the 'brand' key might not always be present or directly available on certain CPU architectures (e.g., ARM-based systems like Raspberry Pi) or with older versions of the library, leading to a KeyError when attempting to access it directly.","error":"KeyError: 'brand'"},{"fix":"If your application uses multiprocessing and is frozen into an executable, add `from multiprocessing import freeze_support; if __name__ == '__main__': freeze_support()` at the very beginning of your main script file.","cause":"When `py-cpuinfo` is bundled into an executable using PyInstaller or Cx_freeze, it can sometimes cause issues like high CPU usage or multiple processes spawning due to how the library interacts with the process environment during freezing.","error":"py-cpuinfo module not working correctly when compiling using pyinstaller or Cx_freeze"},{"fix":"Try to upgrade `py-cpuinfo` to meet the dependency requirements using `pip install --upgrade py-cpuinfo` or explicitly install the required version: `pip install py-cpuinfo>=9.0.0`. If conflicts persist, consider creating a virtual environment or resolving broader dependency issues among your installed packages.","cause":"This error occurs when a project or another installed package has a dependency on a specific version range of `py-cpuinfo` (e.g., `>=9.0.0`), but an incompatible version is currently installed, or a conflicting requirement forces an older version.","error":"ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. inference-sdk 0.9.23 requires py-cpuinfo>=9.0.0, but you have py-cpuinfo 3.3.0 which is incompatible."}],"ecosystem":"pypi","meta_description":null,"install_score":100,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"9.0.0","cli_name":"cpuinfo","cli_version":"9.0.0","type":"library","homepage":null,"github":"https://github.com/workhorsy/py-cpuinfo","docs":null,"changelog":null,"pypi":"https://pypi.org/project/py-cpuinfo/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-27","next_check":"2026-07-28","install_tag":"verified"}}