{"id":10091,"library":"pyeapi","title":"Python Client for Arista eAPI","description":"pyeapi is a Python client library for interacting with Arista EOS devices via their eAPI. It provides a simple, Pythonic interface for sending commands, parsing responses, and managing network configurations. The current version is 1.0.4, with releases occurring periodically to address bugs and introduce minor enhancements.","status":"active","version":"1.0.4","language":"en","source_language":"en","source_url":"https://github.com/arista-eosplus/pyeapi","tags":["networking","arista","eos","eapi","network automation","cli"],"install":[{"cmd":"pip install pyeapi","lang":"bash","label":"Install pyeapi"}],"dependencies":[],"imports":[{"note":"The Node class is typically imported directly from pyeapi.client for ease of use, rather than accessing it as an attribute of the pyeapi.client module.","wrong":"import pyeapi.client.Node","symbol":"Node","correct":"from pyeapi.client import Node"},{"note":"The connect function is a top-level function of the pyeapi package, used to establish a connection to an Arista EOS device.","symbol":"connect","correct":"import pyeapi\nnode = pyeapi.connect(host='10.0.0.1')"}],"quickstart":{"code":"import pyeapi\nimport os\n\n# Configure connection details (e.g., in a YAML file or environment variables)\n# For quickstart, using environment variables as placeholders:\nHOST = os.environ.get('PYEAPI_HOST', '10.0.0.1')\nUSERNAME = os.environ.get('PYEAPI_USERNAME', 'admin')\nPASSWORD = os.environ.get('PYEAPI_PASSWORD', 'arista')\n\n# A more robust setup would use a pyeapi.conf file or direct dictionary config\n# For simplicity, we'll create a dictionary config for direct connection\n\nnode_config = {\n    'transport': 'https',\n    'host': HOST,\n    'username': USERNAME,\n    'password': PASSWORD,\n    'port': 443,\n    'timeout': 30\n}\n\ntry:\n    # Connect to the Arista EOS device\n    node = pyeapi.connect(**node_config)\n    print(f\"Successfully connected to {HOST}\")\n\n    # Run a 'show version' command\n    response = node.run_commands(['show version'])\n    print(\"\\n--- Device Version ---\")\n    print(f\"EOS Version: {response[0]['version']}\")\n    print(f\"Hostname: {response[0]['hostname']}\")\n\n    # Run a 'show interfaces' command\n    interfaces_response = node.run_commands(['show interfaces'])\n    print(\"\\n--- Interfaces Status ---\")\n    for intf_name, intf_data in interfaces_response[0]['interfaces'].items():\n        print(f\"  {intf_name}: {intf_data['lineProtocolStatus']} (Admin: {intf_data['interfaceStatus']})\")\n\nexcept pyeapi.eapilib.EapiError as e:\n    print(f\"EAPI Error: {e}\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")\n","lang":"python","description":"This example demonstrates how to connect to an Arista EOS device using `pyeapi.connect` and execute simple 'show' commands. It uses environment variables as placeholders for credentials, which should be replaced with actual values or a `pyeapi.conf` file for production use. It then prints the device's EOS version, hostname, and the status of its network interfaces."},"warnings":[{"fix":"Upgrade to Python 3.7 or newer. If you must use Python 2, use pyeapi versions prior to 1.0.0 (e.g., 0.8.x).","message":"pyeapi v1.0.0 and later are Python 3 only. Python 2.7 is no longer supported.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Ensure your environment uses Python 3.7 or a later 3.x release. Check your Python version with `python --version`.","message":"pyeapi v1.0.0 and later require Python 3.7 as the minimum supported Python version.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Upgrade your Arista EOS version to 4.22 or newer if running pyeapi on the switch itself. This limitation does not apply to off-box usage.","message":"For on-box deployments (pyeapi running directly on the Arista switch), Arista EOS 4.22 or later is required for pyeapi v1.0.0+.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade pyeapi to version 1.0.2 or the latest available stable release using `pip install --upgrade pyeapi`.","message":"Version 1.0.2 provided a critical bug fix. It is strongly advised to upgrade to 1.0.2 or later to avoid potential issues introduced in earlier 1.x releases.","severity":"gotcha","affected_versions":"1.0.0, 1.0.1"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Install the library using pip: `pip install pyeapi`.","cause":"The pyeapi library is not installed in the active Python environment.","error":"No module named 'pyeapi'"},{"fix":"Verify network connectivity to the device (e.g., `ping`). Ensure eAPI is enabled on the Arista switch (`management api http-command` or `management api https-command` in config mode). Check firewall rules and the specified port (default 80 for HTTP, 443 for HTTPS).","cause":"The eAPI service is not running or accessible on the target device, or there's a network connectivity issue (firewall, routing).","error":"pyeapi.eapilib.EapiError: Failed to connect to eAPI: Connection refused"},{"fix":"Double-check the username and password configured for eAPI access on the Arista switch. Ensure they match the credentials passed to `pyeapi.connect`.","cause":"Incorrect username or password provided for the eAPI connection.","error":"pyeapi.eapilib.EapiError: Failed to connect to eAPI: Authentication failed"},{"fix":"Review the exact command syntax for Arista EOS. Test the command directly on the switch CLI to ensure it's valid. Some commands require 'enable' mode or specific configuration contexts.","cause":"The command sent to the device is syntactically incorrect, not supported, or used in the wrong mode for the current eAPI context.","error":"pyeapi.eapilib.EapiError: 'interface Ethernet1' failed with error 'Invalid command'"}]}