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?

1 Answer 1

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)
Sign up to request clarification or add additional context in comments.

1 Comment

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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.