09-26-2024 04:43 AM
Hello guys,
Upon enabling the NPV feature on my Cisco switch I found an error,
I have no idea if this is the real reason for the error, but this is the only different thing I did in this switch,
I encountered an issue accessing the Cisco library. In the standard switch configuration,
where the NPV mode is disabled, we typically import the library named "cisco" and utilize its functions,
specifically "cli" and "clid," based on the required use case.
Steps to Reproduce:
09-26-2024 06:26 AM
@vinicius-mariano-afonso odd one, not seen this - based only on the error you have the python module six
is not installed on this device, this module is commonly used for compatibility between python 2 and 3, providing a unified interface for various language features. What version of python are you running here looks like python 3? You might be able to fix this with pip install six. Also try this and share your output, be interesting to see this output.
# >>> import cisco
# >>> help(cisco)
Help on module cisco:
NAME
cisco - commands that integrate with CLI
FILE
(built-in)
FUNCTIONS
cli(...)
execute a cli command
clid(...)
execute a cli command, return name/value pairs
clip(...)
execute a cli command, dont return it, just display it
set_vrf(...)
specify the vrf name for socket operations
It could be bug on the version, seen something like this, but not the same. So its always worth checking the version release notes too.
Hope this helps.
09-26-2024 06:54 AM
Hello!
I'm using Python 3.8.14, and I can't use pip
09-26-2024 07:40 AM
@vinicius-mariano-afonso what was the output from the help(cisco)? It looks like from your screen grab you are trying this from the exec prompt on the cli, in or to do this, you would need to run (or pip3)
nxos# guestshell run pip install six
or go into guestshell, the linux side of the switch
nxos# guestshell
[admin@guestshell ~]$ pip install six
Hope this helps.
09-26-2024 08:11 AM
@vinicius-mariano-afonso i just has a second thought.... cli is not part of the Cisco package. So you do not need six package installed. Just import cli and this should work.
nxos# guestshell run python
Python 2.7.5 (default, Jun 28 2022, 15:30:04)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from cisco import cli
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name cli
>>> from cisco import clid
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name clid
>>> import cli
>>>
>>> help(cli)
Help on module cli:
NAME
cli
FILE
/usr/lib64/python2.7/site-packages/cli.py
FUNCTIONS
cli(cmd)
clid(cmd)
clip(cmd)
>>>
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide