question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

loading ntc templates installed via pip fails with "IsADirectoryError"

See original GitHub issue

Hello

when I am using textfsm installed via pip I get this error:

Traceback (most recent call last):
  File "/home/jo/foo/netmiko-bug/test.py", line 4, in <module>
    print(router.send_command("show int desc", use_textfsm=True))
  File "/home/jo/foo/netmiko-bug/lib/python3.9/site-packages/netmiko/utilities.py", line 429, in wrapper_decorator
    return func(self, *args, **kwargs)
  File "/home/jo/foo/netmiko-bug/lib/python3.9/site-packages/netmiko/base_connection.py", line 1538, in send_command
    structured_output = get_structured_data(
  File "/home/jo/foo/netmiko-bug/lib/python3.9/site-packages/netmiko/utilities.py", line 340, in get_structured_data
    template_dir = get_template_dir()
  File "/home/jo/foo/netmiko-bug/lib/python3.9/site-packages/netmiko/utilities.py", line 277, in get_template_dir
    with importresources_path(
  File "/usr/lib/foo/contextlib.py", line 117, in __enter__
    return next(self.gen)
  File "/usr/lib/python3.9/importlib/resources.py", line 175, in _path_from_reader
    opener_reader = reader.open_resource(norm_resource)
  File "<frozen importlib._bootstrap_external>", line 995, in open_resource
IsADirectoryError: [Errno 21] Is a directory: '/home/jo/foo/netmiko-bug/lib/python3.9/site-packages/ntc_templates/templates'

Environment is: Python 3.9.0 netmiko 3.3.2 ntc-templates 1.6.0 textfsm 1.1.0 venv installed via

python3 -m venv .
source bin/activate
pip install netmiko ntc_templates

The templates and the index file are in /home/jo/foo/netmiko-bug/lib/python3.9/site-packages/ntc_templates/templates as expected. Setting the NET_TEXTFSM environment variable to this path works as expected.

the script I run is this:

from netmiko import Netmiko

router = Netmiko(host="router.example.com", username="admin", password="somepass", secret="somesecret", device_type="cisco_xr")
print(router.send_command("show int desc", use_textfsm=True))

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
hacizeynalcommented, Mar 4, 2022

@ktbyers , thanks a lot, issue was resolved after installing the latest netmiko version as you stated, in my venv it was not showing the latest one, appreciate your help and wish you a nice weekend ahead! 😃

1reaction
ktbyerscommented, Jun 19, 2021

Fixed in this PR:

https://github.com/ktbyers/netmiko/pull/2274

This was a Python 3.9 issue/change.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ntc-templates - PyPI
TextFSM Templates for Network Devices, and Python wrapper for TextFSM's CliTable. ... The project can be installed using either Git + Poetry or...
Read more >
Netmiko TEXTSFM Windows 10 issues - Stack Overflow
When I run this it works fine. When I add the use_textfsm=True to the results, I get a permission error where the templates...
Read more >
netmiko - Bountysource
I am trying to copy asa-rest plugin to CISCO ASA DISK0: It is getting copied but same also giving error. ### SCRIPT: from...
Read more >
Netmiko and TextFSM - Python for Network Engineers
Now that both Netmiko and ntc-templates have been installed, how do we tell Netmiko to use the TextFSM parsing capability. First, look at...
Read more >
Parsing Strategies - NTC Templates using TextFSM
This post will dive deeper into using NTC Templates to parse ... make sure you have ntc-templates installed via pip install ntc-templates ....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found