Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-8615

ExecuteScript with python when use module directory

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 1.13.2
    • Fix Version/s: None
    • Component/s: Extensions
    • Labels:
    • Environment:
      debian linux
    • Flags:
      Important

      Description

       

      I use additional module "pytz" in python, this module directory is locate in "/usr/local/lib/python3.9/site-packages"

      I use  sample1 in "Script Body" : (no comment)

      from org.python.core.util.FileUtil import wrap
      from org.apache.nifi.processors.script import ExecuteScript
      from datetime import datetime, tzinfo

      flow_file = session.get()

      import pytz
      from pytz import timezone

      utc = pytz.utc
      eastern = timezone('US/Eastern')

      flow_file = session.putAttribute(flow_file, 'timezone', eastern.zone)
      flow_file = session.putAttribute(flow_file, 'utc', utc.zone)

      flow_file = session.putAttribute(flow_file, 'test', 'salut')

      session.transfer(flow_file, ExecuteScript.REL_SUCCESS)

       

      and sample2 with comment : __ 

      from org.python.core.util.FileUtil import wrap
      from org.apache.nifi.processors.script import ExecuteScript
      from datetime import datetime, tzinfo

      flow_file = session.get()

      """

      import pytz
      from pytz import timezone

      utc = pytz.utc
      eastern = timezone('US/Eastern')

      flow_file = session.putAttribute(flow_file, 'timezone', eastern.zone)
      flow_file = session.putAttribute(flow_file, 'utc', utc.zone)

      """

      flow_file = session.putAttribute(flow_file, 'test', 'salut')

      session.transfer(flow_file, ExecuteScript.REL_SUCCESS)

       

      Try 1

      When use sample1 in version 1.13.2 ExecuteScript make error " : 
      ERROR [Timer-Driven Process Thread-4] o.a.nifi.processors.script.ExecuteScript ExecuteScript[id=790ea9a2-0179-1000-a662-30042349b329] Failed to process session due to org.apache.nifi.processor.exception.ProcessException: javax.script.ScriptException: ImportError: No module named pytz in <script> at line number 6: org.apache.nifi.processor.exception.ProcessException: javax.script.ScriptException: ImportError: No module named pytz in <script> at line number 6
      org.apache.nifi.processor.exception.ProcessException: javax.script.ScriptException: ImportError: No module named pytz in <script> at line number 6

      with version 1.12.1 we have no error and I have output flowfile with new attribute

       

      Try 2

      When use sample1 in version 1.13.2 ExecuteScript make error " : **

      ERROR [Timer-Driven Process Thread-4] o.a.nifi.processors.script.ExecuteScript ExecuteScript[id=790ea9a2-0179-1000-a662-30042349b329] Failed to process session due to org.apache.nifi.processor.exception.ProcessException: javax.script.ScriptException: ImportError: No module named pytz in <script> at line number 6: org.apache.nifi.processor.exception.ProcessException: javax.script.ScriptException: ImportError: No module named pytz in <script> at line number 6
      org.apache.nifi.processor.exception.ProcessException: javax.script.ScriptException: ImportError: No module named pytz in <script> at line number 6

      after I change Script boby with sample2 and nifi return the same error .... retry and the same ... ExecutreScript is bogue and we can't show the flowfile in queue.

      ERROR [Timer-Driven Process Thread-4] o.a.nifi.processors.script.ExecuteScript ExecuteScript[id=790ea9a2-0179-1000-a662-30042349b329] Failed to process session due to org.apache.nifi.processor.exception.ProcessException: javax.script.ScriptException: ImportError: No module named pytz in <script> at line number 6: org.apache.nifi.processor.exception.ProcessException: javax.script.ScriptException: ImportError: No module named pytz in <script> at line number 6
      org.apache.nifi.processor.exception.ProcessException: javax.script.ScriptException: ImportError: No module named pytz in <script> at line number 6

       

        Attachments

        1. test_bug.xml
          21 kB
          Aldric DUPONT
        2. Capture3.PNG
          71 kB
          Aldric DUPONT
        3. Capture2.PNG
          51 kB
          Aldric DUPONT

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              a.dupont Aldric DUPONT
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: