cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
867
Views
0
Helpful
2
Replies

unable to run script on NXOS

zeeshan.rommel
Level 1
Level 1

As per the instruction I need to do the following

1. SSH to switch using provided credentials.

2. Run ‘run bash’ to go to bash shell.

3. Goto directory /home/cisco/subscripts/python

4. Copy the required files to /isan/python/scripts/cisco directory. For example, if you want to manage interface configuration using python, copy test_interface.py to /isan/python/scripts/cisco directory.

5. Execute following command to run the script python –m cisco.test_interface The format of the command to be executed is, bash> python -m .

When i run python –m cisco.test_interface it fails with the error

Could not import runpy module

What am I doing wrong here?

Thanks

2 Replies 2

jacoadam
Level 5
Level 5

Hello Zeeshan,

I'm not exactly sure if you're trying to run this code locally or in the lab, but generally in python when you see this error the python script is referencing a library that it doesn't have access too. Try this:

pip install runpy

-or-

python pip install runpy

Also, could you open up the python application and send me any line that has "import" in front of it? They should be mostly at the top of the script.

Thanks!

Jacob

Thanks jacob ..I trying to run it in the lab.. ssh to the switch.. start bash.. copy the script and run it..

the import statements are

import cli

import json


i am trying to run some examples from GitHub - datacenter/who-moved-my-cli: A collection of simple Python scripts to help convert network engineers into progr…