dmiparser

raw JSON →
5.1 verified Sat May 09 auth: no python maintenance

A library to parse dmidecode output into JSON text. Current version 5.1. Project appears to be in maintenance mode with infrequent releases.

pip install dmiparser
error ModuleNotFoundError: No module named 'dmiparser'
cause Incorrect import path or package not installed.
fix
Install: pip install dmiparser, then import: from dmiparser import dmiparser
error AttributeError: module 'dmiparser' has no attribute 'DMIParser'
cause Using import dmiparser instead of from dmiparser import dmiparser.
fix
Use correct import: from dmiparser import dmiparser, then dmiparser.DMIParser()
gotcha Import path is confusing: the PyPI package is 'dmiparser', but the module to import is also 'dmiparser'. Use 'from dmiparser import dmiparser'.
fix Use correct import: from dmiparser import dmiparser
deprecated Parsing via dmidecode requires root privileges. If the command is not available or fails, the parser will receive empty input.
fix Ensure dmidecode is installed and run with sudo, or capture output from a file.

Parse raw dmidecode output to JSON.

from dmiparser import dmiparser
import subprocess, json

# Get dmidecode output (requires root)
try:
    output = subprocess.check_output(['dmidecode'], stderr=subprocess.STDOUT).decode()
except Exception as e:
    output = ""  # fallback if dmidecode not available

parser = dmiparser.DMIParser()
result = parser.parse_text(output)
print(json.dumps(result, indent=2))