Registry / devops / junos-eznc

junos-eznc

JSON →
library2.8.1pypypi✓ verified 85d ago

Junos EZNC is a Python library for automating Juniper Junos devices, simplifying network management tasks for non-programmers. It provides a high-level API to connect to devices, retrieve facts, execute commands, and manage configurations using NETCONF. The current version is 2.7.6, with releases occurring periodically to add features, fix bugs, and ensure compatibility with newer Python versions and underlying dependencies.

pip install junos-eznc
INSTALL
IMPORT
SIG · JUNOS-EZNC
J
junos-eznc
devopspythonv2.8.1
Install
5.5s avg
Import
1134ms
Disk
63MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.8.1 · 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 1.175s · 63.8MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 5.5s · import 1.093s · 65MB
63MB installed
● package 63MB
Code
Verified usage

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

Device
from jnpr.junos import Device
import junos_eznc
The main Device object is located within the `jnpr.junos` namespace, not the top-level package.
ConnectError
from jnpr.junos.exception import ConnectError
Common exception for connection failures.

This quickstart demonstrates how to establish a connection to a Junos device, retrieve basic facts, and properly close the connection. It uses environment variables for credentials, making it safer for sharing. For production environments, `hostkey_verify` should be set to `True` for secure SSH connections.

import os from jnpr.junos import Device from jnpr.junos.exception import ConnectError host = os.environ.get('JUNOS_HOST', 'your_junos_device_ip') user = os.environ.get('JUNOS_USER', 'your_username') password = os.environ.get('JUNOS_PASSWORD', 'your_password') dev = None try: # hostkey_verify=False for labs/quick starts, use True in production dev = Device(host=host, user=user, password=password, port=22, hostkey_verify=False) dev.open() print(f"Connected to device: {dev.hostname}") print(f"Device facts: {dev.facts['hostname']}, {dev.facts['version']}") # Example: Execute a command # rpc_resp = dev.rpc.get_system_uptime_information() # print(rpc_resp.find('.//up-time').text) except ConnectError as err: print(f"Connection error: {err}") except Exception as err: print(f"An error occurred: {err}") finally: if dev and dev.connected: dev.close() print("Disconnected from device.")
Debug
Known issues
breakingField names within some tables (e.g., `VlanTable`, `BfdSessionTable`) were changed in version 2.6.8. Existing scripts relying on old field names will break.
fix
Review release notes for 2.6.8 and update your code to use the new field names (e.g., `vlan-name` instead of `name` for VlanTable, `client-name` for BfdSessionTable).
affects: >=2.6.8
gotchaPyEZ connections must be explicitly opened (`dev.open()`) and closed (`dev.close()`) to release resources. Forgetting to close can lead to lingering sessions or resource exhaustion on the device/client.
fix
Always use a `try...finally` block to ensure `dev.close()` is called, even if errors occur during the connection lifetime. Alternatively, consider using `with Device(...) as dev:` for automatic resource management if your PyEZ version supports it (check documentation).
affects: All
gotchaOlder versions of `junos-eznc` (prior to 2.7.6) may not fully support Python 3.12+ due to underlying dependency changes or internal updates.
fix
Ensure you are using `junos-eznc` version 2.7.6 or newer for official Python 3.12+ compatibility. Always check `requires_python` in `pyproject.toml` or PyPI.
affects: <2.7.6
deprecatedThe `look_for_keys` parameter for SSH authentication was introduced to control SSH agent usage. Older versions might not have this explicit control, defaulting to agent usage.
fix
Upgrade to `junos-eznc` 2.6.7 or later to gain explicit control over `look_for_keys` parameter, allowing `True`/`False` to enable/disable SSH agent lookup.
affects: <2.6.7
Errors
Common errors & fixes
ImportError: cannot import name 'Device' from 'jnpr.junos'
The Python environment does not have `junos-eznc` installed, or it's installed in a different environment, or the import path is incorrect.
fix
Ensure `junos-eznc` is installed via `pip install junos-eznc` in your active virtual environment. Verify the import statement: `from jnpr.junos import Device`.
jnpr.junos.exception.ConnectError: Cannot connect to device: ('paramiko.ssh_exception.AuthenticationException', 'Authentication failed.')
Incorrect username or password, or SSH key authentication failed. This can also occur if the user lacks necessary permissions on the Junos device.
fix
Double-check credentials (username/password, SSH key path). Ensure the user is configured for NETCONF access on the Junos device. Verify network connectivity to the device's SSH port (22).
ncclient.operations.rpc.RPCError: <rpc-error>
A NETCONF RPC call failed on the Junos device. This usually indicates a syntax error in the command sent, invalid configuration, or an operational issue on the device itself.
fix
Examine the full RPC error message for details. This often includes `error-message` and `error-path`. Consult Junos documentation for the correct syntax of the command or configuration being applied.
AttributeError: 'Device' object has no attribute 'facts'
The `facts` attribute (or other operational attributes) is only available after a successful connection has been established using `dev.open()`.
fix
Call `dev.open()` before attempting to access `dev.facts` or other device attributes. Ensure connection success by handling `ConnectError`.
Upgrade
Version history
2.8.1latest on PyPI · released Jun 1, 2026
Audit
Dependencies
ncclientrequiredRequired for NETCONF communication with Junos devices.
juniper-paramikorequiredProvides an SSH client with specific Juniper-related ciphers and enhancements.
Agent activity
6 hits · last 30 days
node
6
Resources
junos-eznc — pip install junos-eznc · libregistry