1

I made a simple program by using Python to access CISCO devices. I am using the Netmiko Textfsm method for this. When I build an .exe using pyinstaller it works fine. However, if I copy the .exe to another PC, it shows an error:

Directory containing TextFSM index file not found.

Please set the NET_TEXTFSM environment variable to point at the directory containing your TextFSM index file.

Alternatively, pip install ntc-templates (if using ntc-templates).

How can I overcome this problem?

Daniel Walker
  • 6,380
  • 5
  • 22
  • 45

1 Answers1

1

The issue is you need to use an absolute path and not a relative path here:

os.environ["NET_TEXTFSM"] = "lib/ntc-templates/templates"

os.path.join should use the absolute path as follows because relative paths are not supported here:

def get_structured_data(raw_output, platform, command):
            """Convert raw CLI output to structured data using TextFSM template."""
            template_dir = get_template_dir()
            index_file = os.path.join('/Users/barissonmez/ntc-templates/templates/', '/Users/barissonmez/ntc-templates/templates/index')
    '/Users/barissonmez/ntc-templates/templates/index'
            textfsm_obj = clitable.CliTable(index_file, template_dir)
Baris Sonmez
  • 477
  • 2
  • 8
  • Should i set etc-templates path everywhere, when i using the .exe file in different PC? Is there have no option to build complete package of .exe without set the path repeatedly? – Mynul Hasan Aug 13 '22 at 12:56