Search code examples
python-3.xautomationnetmiko

the correct way to use nornir plugins


I am a beginner with nornir, I am trying to run nornir plugins but I am having these errors:

Traceback (most recent call last):
  File "nornirpy/start.py", line 2, in <module>
    from nornir.plugins.tasks.commands import commands
ModuleNotFoundError: No module named 'nornir.plugins.tasks.commands'

My start.py file is very basic:

from nornir import InitNornir
from nornir.plugins.tasks.commands import commands
from nornir.core.inventory import Host
from path.to import InventoryPlugin
import json

nr = InitNornir("nornirpy/config.yml")

print(json.dumps(Host.schema(), indent=4))

What is the issue? I am using poetry to organize my project, is there a step I forgot? its not clear to me how can I use plugins in my application.


Solution

  • Hello Somayyah Mohammed;

    First, check the version of nornir you are using. If version > 2.4.0 then module nornir.plugins.tasks.commands is not there. You can remove the import command it should work.