Registry / http-networking / unicon

unicon

JSON →
library26.5pypypiunverified

Unicon is a Python package that provides a unified connection experience to network devices via typical command-line management interfaces (CLI). It serves as the standard CLI connection implementation within the Cisco pyATS framework, offering direct and proxied connections, expect-like programming, and multi-vendor support through an agnostic API. Initially developed internally by Cisco, it was released publicly in late 2017 through Cisco DevNet. [1, 2, 12] The current version is 26.3, released on April 2, 2026, and the project maintains an active release cadence, often aligned with the broader pyATS/Genie framework releases. [2, 23]

pip install unicon
INSTALL
IMPORT
SIG · UNICON
U
unicon
http-networkingpythonv26.5
Install
3.6s avg
Import
Disk
68MB
Pass rate
7/ 10
Env Coverage7 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v26.5 · 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
glibc
py 3.10
✓ —
✓ 3.7s
py 3.11
✕ build_error
✓ 3.43s
py 3.12
✕ build_error
✓ 3.15s
py 3.13
✕ build_error
✓ 3.18s
py 3.9
✓ —
✓ 4.53s
68MB installed
● package 68MB
Code
Verified usage

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

Connection
from unicon import Connection
from unicon.core.connection import Connection

This quickstart demonstrates how to establish a basic CLI connection to a network device using Unicon, execute a command, and then disconnect. It uses environment variables for sensitive credentials for security and easy testing. [12]

import os from unicon.core.connection import Connection # Replace with your device details and credentials device_settings = { 'hostname': os.environ.get('DEVICE_HOSTNAME', '10.0.0.1'), 'os': os.environ.get('DEVICE_OS', 'ios'), # e.g., ios, nxos, iosxe 'type': os.environ.get('DEVICE_TYPE', 'router'), 'username': os.environ.get('DEVICE_USERNAME', 'admin'), 'password': os.environ.get('DEVICE_PASSWORD', 'Cisco123'), 'enable_password': os.environ.get('DEVICE_ENABLE_PASSWORD', 'Cisco123'), } try: # Create a connection instance conn = Connection(hostname=device_settings['hostname'], os=device_settings['os'], type=device_settings['type'], start_state='exec') # Specify the initial state to reach # Provide credentials (Unicon can also retrieve from testbed YAML) conn.settings.CLI_USERNAME = device_settings['username'] conn.settings.CLI_PASSWORD = device_settings['password'] conn.settings.CLI_ENABLE_PASSWORD = device_settings['enable_password'] # Connect to the device print(f"Connecting to {device_settings['hostname']}...") conn.connect() print("Connection successful.") # Execute a command output = conn.execute('show version') print("\n--- show version output ---") print(output) # Disconnect from the device conn.disconnect() print("Disconnected.") except Exception as e: print(f"An error occurred: {e}")
Debug
Known issues
breakingUnicon's Python compatibility officially requires Python 3.8 or newer. Using older Python versions will lead to installation failures or runtime errors.
fix
Ensure your Python environment is 3.8 or higher. Upgrade Python or activate a compatible virtual environment. [2]
affects: < 26.0
gotchaUnicon relies heavily on plugins for specific device platforms and OS capabilities. If you encounter issues connecting to a device or executing specific commands, ensure you have the correct `unicon.plugins` package installed and that it supports your target device/OS combination.
fix
Install `unicon.plugins` (`pip install unicon.plugins`). Refer to Cisco DevNet documentation for supported platforms and necessary plugins for your specific device. [1, 12]
affects: All versions
gotchaWhen using `conn.execute()` with `reply` or `error_pattern` arguments, comprehensively listing all possible CLI error patterns or prompts for a given command can be challenging due to vendor/OS variations. Incomplete patterns may lead to command failures or timeouts.
fix
Start with common error patterns (e.g., `^%Error`, `^% Invalid`, `Timeout`). Test against various error conditions on your target devices. Use regular expressions carefully and consider broad patterns like `%.*?%` for general error messages, then refine to avoid false positives. Consult device documentation for expected error messages. [24]
affects: All versions
Upgrade
Version history
26.5latest on PyPI · released May 28, 2026
Audit
Dependencies
pyyamlrequiredUsed for parsing YAML configurations, common in pyATS testbeds.
PrettyTablerequiredLikely used for formatting output in a tabular manner.
cryptographyrequiredRequired for secure communication protocols like SSH.
Agent activity
24 hits · last 30 days
node
22
OpenAI (training)
1
Resources
unicon — pip install unicon · libregistry