apache-nifijythonexecute-scriptflowfile

NIFI EXECUTESCRIPT Processor failing - No MODULE FOUND


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.


Solution

  • 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.