{"id":7628,"library":"python-ipmi","title":"Python IPMI Library","description":"The `python-ipmi` library provides a pure Python API for interacting with devices via the Intelligent Platform Management Interface (IPMI) protocol. It supports IPMI version 2.0 and offers multiple communication interfaces, including native RMCP (IPMI over LAN), legacy RMCP (requiring the external `ipmitool`), IPMB (requiring a Total Phase Aardvark or Linux `ipmb-dev` driver), and a mock interface for testing. The current version is 0.5.8, released in December 2025, and it actively supports Python > 3.6, with Python 2.x deprecated.","status":"active","version":"0.5.8","language":"en","source_language":"en","source_url":"https://github.com/kontron/python-ipmi","tags":["IPMI","hardware management","system administration","server management","remote management"],"install":[{"cmd":"pip install python-ipmi","lang":"bash","label":"PyPI"}],"dependencies":[{"reason":"Required for 'ipmitool' backend interfaces (legacy RMCP, RMCP+, KCS) if chosen over native RMCP. Must be installed separately on the system PATH.","package":"ipmitool","optional":true},{"reason":"Hardware device required for the 'aardvark' IPMB interface.","package":"Total Phase Aardvark","optional":true},{"reason":"Linux kernel driver for the IPMB interface, as an alternative to the Aardvark hardware.","package":"ipmb-dev driver","optional":true}],"imports":[{"note":"Main library import for core IPMI functionality.","symbol":"pyipmi","correct":"import pyipmi"},{"note":"Required for creating interface instances like RMCP or ipmitool backend.","symbol":"pyipmi.interfaces","correct":"import pyipmi.interfaces"}],"quickstart":{"code":"import os\nimport pyipmi\nimport pyipmi.interfaces\n\n# Environment variables for IPMI connection details\nIPMI_HOST = os.environ.get('IPMI_HOST', '192.168.1.100')\nIPMI_USER = os.environ.get('IPMI_USER', 'admin')\nIPMI_PASSWORD = os.environ.get('IPMI_PASSWORD', 'password')\n\ninterface = None\nconnection = None\ntry:\n    # Using the native RMCP interface (IPMI over LAN)\n    interface = pyipmi.interfaces.create_interface('rmcp')\n    \n    connection = pyipmi.create_connection(interface)\n    connection.target = pyipmi.Target(IPMI_HOST)\n    connection.session.set_session_type_rmcp(username=IPMI_USER, password=IPMI_PASSWORD)\n    \n    print(f\"Attempting to establish session to {IPMI_HOST}...\")\n    connection.session.establish()\n    print(\"Session established successfully.\")\n\n    # Get Device ID command\n    device_id_response = connection.get_device_id()\n    print(f\"Device ID: {device_id_response.device_id_string}\")\n    print(f\"Manufacturer ID: {hex(device_id_response.manufacturer_id)}\")\n    print(f\"Product ID: {hex(device_id_response.product_id)}\")\n    print(f\"Firmware Revision: {device_id_response.firmware_revision.major}.{device_id_response.firmware_revision.minor}\")\n\nexcept pyipmi.errors.IpmiError as e:\n    print(f\"IPMI Error: {e}\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")\nfinally:\n    if connection:\n        try:\n            connection.session.close()\n            print(\"Session closed.\")\n        except Exception as e:\n            print(f\"Error closing session: {e}\")\n","lang":"python","description":"This quickstart demonstrates how to establish an IPMI session using the native RMCP interface and retrieve the device ID. It relies on environment variables for sensitive connection details."},"warnings":[{"fix":"Ensure your project uses Python 3.6 or newer. Upgrade your Python environment if necessary.","message":"Python 2.x support is deprecated. While older documentation mentions Python 3.x support being in beta, the latest PyPI and GitHub README state that Python > 3.6 is currently supported.","severity":"deprecated","affected_versions":"<=0.5.x"},{"fix":"If using `pyipmi.interfaces.create_interface('ipmitool')`, ensure `ipmitool` is installed on your system. For a pure Python solution, use the 'rmcp' interface.","message":"Using the 'ipmitool' interface type requires the external `ipmitool` binary to be installed and accessible in the system's PATH. This is not a pure Python solution and introduces an external dependency.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Implement robust error handling and timeouts around IPMI calls. Consider retries with exponential backoff. If using native RMCP, try switching to the 'ipmitool' backend (with `ipmitool` installed) to see if the issue persists, or test against a BMC simulator to narrow down if it's a library or BMC issue.","message":"The library may occasionally hang during `session.establish()` or certain IPMI command calls (e.g., `get_chassis_status()`), especially if the BMC is under heavy load or unresponsive.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always use `pip install python-ipmi` for installation, even within a Conda environment.","message":"Installing `python-ipmi` via `conda install python-ipmi` is explicitly warned against in the documentation and will not work.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Verify the IPMI host IP address and network connectivity. Check if the BMC is powered on and its IPMI services are enabled. Consider increasing the timeout settings if network latency is expected, though this specific error message implies a hard timeout has been reached.","cause":"The IPMI target (BMC) did not respond within the expected timeframe during session establishment or command execution. This often indicates network issues, an incorrect target IP, or an unresponsive BMC.","error":"Error. timeout: timed out"},{"fix":"Consult the IPMI specification and your BMC's specific documentation to ensure the command parameters are correct. Verify the arguments passed to `python-ipmi` methods match the expected format for your target device. Check GitHub issues for similar problems with your specific BMC model.","cause":"A command was sent with invalid or improperly formatted data for the specific BMC or IPMI version, or the BMC returned a non-success completion code indicating an invalid request.","error":"pyipmi.errors.CompletionCodeError: cc=0xYY desc=Invalid data field in Request"},{"fix":"Ensure the library is installed with `pip install python-ipmi`. Verify that the Python environment where you are running your script is the same one where the library was installed. If using virtual environments, activate it before running your script.","cause":"The `python-ipmi` library was not installed correctly or is not accessible in the current Python environment.","error":"ImportError: cannot import name 'pyipmi'"}]}