Registry / devops / napalm

napalm

JSON →
library5.1.0pypypi✓ verified 85d ago

NAPALM (Network Automation and Programmability Abstraction Layer with Multivendor support) is a Python library that provides a unified API to interact with various network devices from different vendors (e.g., Cisco IOS/XR/NX-OS, Arista EOS, Juniper Junos). It abstracts away vendor-specific complexities, offering a consistent way to retrieve operational data and manage configurations. The current version is 5.1.0, with regular releases, typically major updates every 6-12 months and minor/patch releases in between.

pip install napalm
INSTALL
IMPORT
SIG · NAPALM
N
napalm
devopspythonv5.1.0
Install
11.0s avg
Import
6768ms
Disk
125MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v5.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 6.481s · 139.7MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 11.0s · import 7.056s · 140MB
125MB installed
● package 125MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

get_network_driver
from napalm import get_network_driver
NapalmBaseException
from napalm.base.exceptions import NapalmBaseException
from napalm.exceptions import NapalmBaseException
Exceptions are located under `napalm.base.exceptions` since v3.x.

This quickstart demonstrates how to connect to a network device using NAPALM, retrieve basic device facts, and properly close the connection. Remember to replace the placeholder credentials and device type with your actual network environment details. For production, use environment variables or a secure credential management system.

from napalm import get_network_driver def connect_and_get_facts(hostname, username, password): try: driver = get_network_driver("ios") # Replace 'ios' with your device type (e.g., 'eos', 'junos', 'nxos') device = driver( hostname, username, password, optional_args={ "port": 22, # Or 830 for NETCONF, 443 for API "secret": "", # If using privilege escalation "config_file": None # Path to an external config file } ) print(f"Connecting to {hostname}...") device.open() print(f"Successfully connected to {hostname}.") facts = device.get_facts() print("Device Facts:") for k, v in facts.items(): print(f" {k}: {v}") # Example: Get interface details # interfaces = device.get_interfaces() # print("Interfaces:", interfaces) except Exception as e: print(f"Error connecting or retrieving data: {e}") finally: if 'device' in locals() and device.is_open: device.close() print(f"Disconnected from {hostname}.") if __name__ == "__main__": # Replace with your actual device details DEVICE_HOSTNAME = os.environ.get('NAPALM_TEST_HOSTNAME', '192.168.1.1') DEVICE_USERNAME = os.environ.get('NAPALM_TEST_USERNAME', 'admin') DEVICE_PASSWORD = os.environ.get('NAPALM_TEST_PASSWORD', 'password') # Make sure to set these environment variables or change the default values connect_and_get_facts(DEVICE_HOSTNAME, DEVICE_USERNAME, DEVICE_PASSWORD)
napalm --version
Debug
Known issues
breakingPython 3.8 support was dropped in NAPALM v5.1.0. NAPALM now requires Python 3.9+ (including 3.13 support).
fix
Upgrade your Python environment to 3.9 or newer. If you must use Python 3.8, pin NAPALM to `<5.1.0`.
affects: >=5.1.0
breakingArista EOS versions older than 4.23 are no longer supported starting with NAPALM v5.0.0. Additionally, the `eos_fn0039_config` optional argument for EOS was removed.
fix
Ensure your Arista EOS devices are running version 4.23 or newer. Remove the `eos_fn0039_config` argument from your driver initialization if previously used.
affects: >=5.0.0
gotchaNAPALM v4.0.0 introduced extensive type hinting. While not a breaking change in terms of runtime behavior, it impacts static analysis and how developers might perceive function signatures. If relying on introspection or type checks, be aware of these additions.
fix
No specific fix required, but be aware of the changed metadata for type-aware tooling.
affects: >=4.0.0
gotchaThe behavior of `force_no_enable` for Netmiko-based drivers (like IOS and NX-OS) was fixed in v3.1.0. If you maintain a third-party driver that uses Netmiko but does not utilize `enable` features, older NAPALM versions might have exhibited unexpected behavior.
fix
It is recommended to use NAPALM v3.1.0 or newer for more consistent `force_no_enable` behavior in custom drivers.
affects: <3.1.0
Errors
Common errors & fixes
napalm.base.exceptions.ConnectionException: Cannot connect to device 192.168.1.1
Network connectivity issues, incorrect hostname/IP, wrong port, firewall blocking, or invalid device credentials/access method.
fix
Verify network reachability (ping), check SSH/API port (default 22 for SSH, 443/830 for API/NETCONF), ensure correct username/password, and confirm device is configured for programmatic access (SSH, API enabled, correct user privileges).
TypeError: 'NoneType' object is not callable (e.g., when calling `get_network_driver('nonexistent_driver')`)
The specified network driver name is incorrect, unsupported, or a required underlying dependency for the driver is not installed.
fix
Double-check the driver name against NAPALM's documentation (e.g., 'ios', 'eos', 'junos', 'nxos'). If it's a valid driver, ensure all necessary optional dependencies (e.g., `pip install napalm[full]` or specific driver extras) are installed.
napalm.base.exceptions.MergeConfigException: Configuration validation failed: ... (followed by device error messages)
The configuration payload provided to `load_merge_candidate` or `load_replace_candidate` contains syntax errors or conflicts with the device's current configuration.
fix
Review the configuration changes being pushed. Test the configuration snippet manually on the device CLI to ensure it's valid. Inspect the device's error messages for specific syntax issues.
napalm.base.exceptions.LockError: Unable to lock device's configuration
Another process or user has an exclusive lock on the device's configuration, preventing NAPALM from making changes.
fix
Wait for the other process/user to release the lock, or manually clear the lock on the device if no active changes are being performed. In some cases, increasing the `lock_config_timeout` optional argument might help if the device is slow to respond.
Upgrade
Version history
5.1.0latest on PyPI · released Aug 5, 2025
Audit
Dependencies
netmikorequiredUnderlying SSH/Telnet library for many drivers
pyeapioptionalArista EOS driver
junos-ezncoptionalJuniper Junos driver
ncclientoptionalNETCONF protocol support for various drivers
Agent activity
4 hits · last 30 days
node
4
Resources
napalm — pip install napalm · libregistry