pyATS Version Update

Feb. 9, 2021

Run 'pyATS version update' after updating pyATS


If, like me, you had step away from pyATS (https://developer.cisco.com/docs/pyats) and try to upgrade the pyATS software via 'pip install --upgrade pyats', it might be a good idea to use 'pyATS version update' after.

Summary

According to the documentation, 'pyats version update' is a one-click update of all your pyATS and dependency packages. The intent is to simplify common upgrade/downgrade process, eliminate the need to fiddle with pip command, and maintain a seamless user experience through packageing refractor/changes.

Long Story

Here is more context to how I came about finding out the command. I had a working pyATS testbed on a Linux host with two simple scripts. They were around version 19.x back in 2019. Since I used pip to install the previous pyATS software, I used 'pip install --upgrade pyATS' to update to the latest version, 20.12. However, now my previously working simple test is now giving me some error about unable to load unicon.Unicon:

pyats.utils.exceptions.SchemaError: import_from_name('unicon.Unicon') raised ImportError("Failed to import 'unicon.Unicon'",)

My testbed and script is very simple by design, so it was pretty puzzling. For reference, here are the testbed and the script (same as on the GitHub Repo):

$ cat pyats_1.py

#!/usr/bin/env python3

#

# derived from https://devnet-pubhub-site.s3.amazonaws.com/media/pyats/docs/getting_started/index.html

#

from pyats.topology import loader

# load testbed

testbed = loader.load('testbed_1.yml')

# access the device

testbed.devices

ios_1 = testbed.devices['iosv-1']

# establish connectivity

ios_1.connect()

# issue command

print(ios_1.execute('show version'))

# disconnect

ios_1.disconnect()

$ cat testbed_1.yml

testbed:

name: Chapter_15_pyATS

tacacs:

username: cisco

passwords:

tacacs: cisco

enable: cisco

devices:

iosv-1:

alias: iosv-1

type: ios

connections:

defaults:

class: unicon.Unicon

debug: True

management:

ip: 172.16.1.20

protocol: ssh

topology:

iosv-1:

interfaces:

GigabitEthernet0/2:

ipv4: 10.0.0.5/30

link: link-1

type: ethernet

Loopback0:

ipv4: 192.168.0.3/32

link: iosv-1_Loopback0

type: loopback

After a while, I decided to run the pyATS Sample Scripts as directed on the installation page. It gave me the right clue to move forward:

$ pyats run job basic_example_job.py

2021-01-27T13:32:57: %EASYPY-INFO: Your environment has mismatched pyATS versions!

2021-01-27T13:32:57: %EASYPY-INFO:

2021-01-27T13:32:57: %EASYPY-INFO:   Package              Version

2021-01-27T13:32:57: %EASYPY-INFO:   -------------------- -------

2021-01-27T13:32:57: %EASYPY-INFO:   pyats                20.12

2021-01-27T13:32:57: %EASYPY-INFO:   pyats.aereport       20.12

2021-01-27T13:32:57: %EASYPY-INFO:   pyats.aetest         20.12

2021-01-27T13:32:57: %EASYPY-INFO:   pyats.async          20.12

2021-01-27T13:32:57: %EASYPY-INFO:   pyats.connections    20.12

2021-01-27T13:32:57: %EASYPY-INFO:   pyats.datastructures 20.12

2021-01-27T13:32:57: %EASYPY-INFO:   pyats.easypy         20.12

2021-01-27T13:32:57: %EASYPY-INFO:   pyats.examples       19.6

2021-01-27T13:32:57: %EASYPY-INFO:   pyats.kleenex        20.12

2021-01-27T13:32:57: %EASYPY-INFO:   pyats.log            20.12.2

2021-01-27T13:32:57: %EASYPY-INFO:   pyats.reporter       20.12.1

2021-01-27T13:32:57: %EASYPY-INFO:   pyats.results        20.12

2021-01-27T13:32:57: %EASYPY-INFO:   pyats.tcl            20.12

2021-01-27T13:32:57: %EASYPY-INFO:   pyats.templates      19.6

2021-01-27T13:32:57: %EASYPY-INFO:   pyats.topology       20.12

2021-01-27T13:32:57: %EASYPY-INFO:   pyats.utils          20.12

2021-01-27T13:32:57: %EASYPY-INFO:   unicon               20.12

2021-01-27T13:32:57: %EASYPY-INFO:   unicon.plugins       20.12

2021-01-27T13:32:57: %EASYPY-INFO:

2021-01-27T13:32:57: %EASYPY-INFO:

2021-01-27T13:32:57: %EASYPY-INFO: Fix version mismatches by updating all packages to the same {major}.{minor}.x version range using:

2021-01-27T13:32:57: %EASYPY-INFO:

2021-01-27T13:32:57: %EASYPY-INFO:     pyats version update [version]

2021-01-27T13:32:57: %EASYPY-INFO:

I wanted to document it somewhere both as a reminder for myself as well as help others if they run into the same issue.

Happy Coding!

Eric

Return to blog