0

I am trying to import modules into executescript processor in nifi. As suggested , I. am giving full path into the modules directory.

example: Module Directory: /var/lib/nifi/Levenshtein --> which contains necessary files for the script.

Furthermore, In the script also I have set the system path pointing to use that module directory My code Looks something like this

import re
import datetime
import sys
sys.path.append('/var/lib/nifi/Levenshtein')

import Levenshtein

When I am running the processor with above code it fails.

ERROR: No Module named Levenshtein in at line number 3.

Bugbeeb
  • 2,021
  • 1
  • 9
  • 26

2 Answers2

1

If this particular library is a "native module" (compiled C code), Jython (the Python execution engine used by ExecuteScript) will not be able to load it. ExecuteScript in NiFi using Python can only use pure Python code.

The work-around is to use ExecuteProcess or ExecuteStreamCommand and invoke python <my_script.py> on the command-line, which can handle various Python versions, native modules, etc. This execution will occur outside the JVM and use real Python, not Jython.

Andy
  • 13,916
  • 1
  • 36
  • 78
0

To sum up what Andy said, this Levensthein module is written in C and cannot be executed by a Java virtual machine, assuming you are running a Jython implementation.

Bugbeeb
  • 2,021
  • 1
  • 9
  • 26