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
py 3.11
✕ build_error
✓ 3.35s
py 3.12
✕ build_error
✓ 3.03s
py 3.13
✕ build_error
✓ 3.13s
68MB installed
● package 68MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Connection
✓ from unicon import Connection
Unicon plugins extend the base unicon.Connection class. Users interact with the Connection object from the 'unicon' package, and the relevant plugins are automatically loaded based on device OS/platform.
This quickstart demonstrates how to establish a basic CLI connection to a network device using `unicon.Connection`, leveraging the plugins to handle device-specific interactions. It uses environment variables for credentials, which is a common practice in automation. For a real environment, device details are typically managed via a pyATS Testbed YAML file.
import os
from unicon import Connection
# Example: Connecting to an IOS XE device
# In a real scenario, device details and credentials would typically come from a pyATS testbed YAML file.
# For a quick start, we'll simulate a direct connection.
hostname = os.environ.get('DEVICE_HOSTNAME', 'your_device_ip_or_hostname')
username = os.environ.get('DEVICE_USERNAME', 'admin')
password = os.environ.get('DEVICE_PASSWORD', 'Cisco123')
enable_password = os.environ.get('DEVICE_ENABLE_PASSWORD', 'Cisco123')
# Instantiate a connection object for an IOSXE device
# The 'os' argument directs Unicon to load the appropriate plugin.
# Other parameters like 'platform' and 'model' can further refine plugin selection.
try:
print(f"Attempting to connect to {hostname} (OS: iosxe)...")
connection = Connection(
hostname=hostname,
os='iosxe',
start=['ssh {username}'], # Specifies how to start the connection
log_file='unicon_connection.log', # Optional: logs interaction
init_exec_commands=['terminal length 0', 'terminal width 0'], # Initial commands to run
custom_callbacks={
'password': lambda: password,
'enable_password': lambda: enable_password
}
)
connection.connect()
print(f"Successfully connected to {hostname}")
# Execute a command
output = connection.execute('show version')
print("\n--- show version output ---\n")
print(output[:500]) # Print first 500 characters of output
print("\n---------------------------")
# Configure the device (example - requires 'configure' service for the plugin)
# config_commands = ['interface Loopback100', 'description Test Loopback']
# print(f"\nAttempting to configure: {config_commands}")
# connection.configure(config_commands)
# print("Configuration applied.")
except Exception as e:
print(f"Connection failed: {e}")
finally:
if 'connection' in locals() and connection.is_connected():
connection.disconnect()
print(f"Disconnected from {hostname}")
unicon --version
Upgrade
Version history
26.5latest on PyPI · released May 28, 2026
Audit
Dependencies
uniconrequiredThis package is the plugin component of Unicon and requires the main unicon library for core functionality.
pyyamlrequiredRequired for configuration and data handling.
PrettyTablerequiredUsed for formatted output in some utilities.
cryptographyrequiredRequired for secure communication (e.g., SSH). Version 43.0 or higher is specified.