<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Unable to import python external modules in nifi execute script in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Unable-to-import-python-external-modules-in-nifi-execute/m-p/350048#M235858</link>
    <description>&lt;P&gt;Tried executing following python script body &amp;amp; Module directory as&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import json
import java.io
from org.apache.commons.io import IOUtils
from java.nio.charset import StandardCharsets
from org.apache.nifi.processor.io import StreamCallback
#from google.cloud import bigquery
#from google.oauth2 import service_account
import google

class ModJSON(StreamCallback):
    def __init__(self):
        pass
    def process(self, inputStream, outputStream):
        text = IOUtils.toString(inputStream, StandardCharsets.UTF_8)
        obj = json.loads(text)
        print(text)
        outputStream.write(bytearray(json.dumps(obj, indent=4).encode('utf-8')))

flowFile = session.get()
if (flowFile != None):
  flowFile = session.write(flowFile, ModJSON())
  flowFile = session.putAttribute(flowFile, "filename", flowFile.getAttribute('filename')+'_translated.json')
  session.transfer(flowFile, REL_SUCCESS)
session.commit()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Module Directory&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/Users/bonthala/Library/Python/2.7/lib/python/site-packages/&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Received the following error&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;2022-08-13 00:14:56,948 ERROR [Timer-Driven Process Thread-6] o.a.nifi.processors.script.ExecuteScript ExecuteScript[id=8df016ea-0182-1000-35d7-40765b666df2] Failed to properly initialize Processor. If still scheduled to run, NiFi will attempt to initialize and run the Processor again after the 'Administrative Yield Duration' has elapsed. Failure is due to org.apache.nifi.processor.exception.ProcessException: Could not instantiate script engines: java.io.IOException: Mark invalid
↳ causes: java.io.IOException: Mark invalid
	at java.base/java.io.BufferedReader.reset(BufferedReader.java:517)
	at org.python.core.ParserFacade.parseExpressionOrModule(ParserFacade.java:133)
	at org.python.util.PythonInterpreter.compile(PythonInterpreter.java:320)
	at org.python.util.PythonInterpreter.compile(PythonInterpreter.java:316)
	at org.python.util.PythonInterpreter.compile(PythonInterpreter.java:308)
	at org.python.jsr223.PyScriptEngine.compileScript(PyScriptEngine.java:87)
	at org.python.jsr223.PyScriptEngine.compile(PyScriptEngine.java:76)
	at org.apache.nifi.script.impl.JythonScriptRunner.&amp;lt;init&amp;gt;(JythonScriptRunner.java:42)
	at org.apache.nifi.script.ScriptRunnerFactory.createScriptRunner(ScriptRunnerFactory.java:56)
	at org.apache.nifi.script.ScriptingComponentHelper.setupScriptRunners(ScriptingComponentHelper.java:250)
	at org.apache.nifi.script.ScriptingComponentHelper.setupScriptRunners(ScriptingComponentHelper.java:211)
	at org.apache.nifi.processors.script.ExecuteScript.setup(ExecuteScript.java:176)
	at jdk.internal.reflect.GeneratedMethodAccessor552.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:145)
	at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:133)
	at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:78)
	at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotation(ReflectionUtils.java:55)
	at org.apache.nifi.controller.StandardProcessorNode.lambda$initiateStart$6(StandardProcessorNode.java:1653)
	at org.apache.nifi.engine.FlowEngine$3.call(FlowEngine.java:123)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
java.io.IOException: java.io.IOException: Mark invalid

↳ causes: javax.script.ScriptException: java.io.IOException: java.io.IOException: Mark invalid
↳ causes: org.apache.nifi.processor.exception.ProcessException: Could not instantiate script engines
org.apache.nifi.processor.exception.ProcessException: Could not instantiate script engines
	at org.apache.nifi.script.ScriptingComponentHelper.setupScriptRunners(ScriptingComponentHelper.java:256)
	at org.apache.nifi.script.ScriptingComponentHelper.setupScriptRunners(ScriptingComponentHelper.java:211)
	at org.apache.nifi.processors.script.ExecuteScript.setup(ExecuteScript.java:176)
	at jdk.internal.reflect.GeneratedMethodAccessor552.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:145)
	at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:133)
	at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:78)
	at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotation(ReflectionUtils.java:55)
	at org.apache.nifi.controller.StandardProcessorNode.lambda$initiateStart$6(StandardProcessorNode.java:1653)
	at org.apache.nifi.engine.FlowEngine$3.call(FlowEngine.java:123)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: javax.script.ScriptException: java.io.IOException: java.io.IOException: Mark invalid
	at org.python.jsr223.PyScriptEngine.scriptException(PyScriptEngine.java:226)
	at org.python.jsr223.PyScriptEngine.compileScript(PyScriptEngine.java:93)
	at org.python.jsr223.PyScriptEngine.compile(PyScriptEngine.java:76)
	at org.apache.nifi.script.impl.JythonScriptRunner.&amp;lt;init&amp;gt;(JythonScriptRunner.java:42)
	at org.apache.nifi.script.ScriptRunnerFactory.createScriptRunner(ScriptRunnerFactory.java:56)
	at org.apache.nifi.script.ScriptingComponentHelper.setupScriptRunners(ScriptingComponentHelper.java:250)
	... 16 common frames omitted
Caused by: org.python.core.PyException: null
	at org.python.core.Py.JavaError(Py.java:552)
	at org.python.core.ParserFacade.fixParseError(ParserFacade.java:107)
	at org.python.core.ParserFacade.parseExpressionOrModule(ParserFacade.java:136)
	at org.python.util.PythonInterpreter.compile(PythonInterpreter.java:320)
	at org.python.util.PythonInterpreter.compile(PythonInterpreter.java:316)
	at org.python.util.PythonInterpreter.compile(PythonInterpreter.java:308)
	at org.python.jsr223.PyScriptEngine.compileScript(PyScriptEngine.java:87)
	... 20 common frames omitted
Caused by: java.io.IOException: Mark invalid
	at java.base/java.io.BufferedReader.reset(BufferedReader.java:517)
	at org.python.core.ParserFacade.parseExpressionOrModule(ParserFacade.java:133)
	... 24 common frames omitted&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Python sys path&lt;/P&gt;&lt;LI-CODE lang="python"&gt;~ » python                                                                                                                                                              bonthala@Offfice-Admins-MacBook-Pro

WARNING: Python 2.7 is not recommended.
This version is included in macOS for compatibility with legacy software.
Future versions of macOS will not include Python 2.7.
Instead, it is recommended that you transition to using 'python3' from within Terminal.

Python 2.7.16 (default, Jul  5 2020, 02:24:03)
[GCC 4.2.1 Compatible Apple LLVM 11.0.3 (clang-1103.0.29.21) (-macos10.15-objc- on darwin
Type "help", "copyright", "credits" or "license" for more information.
&amp;gt;&amp;gt;&amp;gt; import sys
&amp;gt;&amp;gt;&amp;gt; sys.path
['', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/Users/bonthala/Library/Python/2.7/lib/python/site-packages', '/Library/Python/2.7/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '/Library/Python/2.7/site-packages/virtualenv-20.0.27-py2.7.egg', '/Library/Python/2.7/site-packages/importlib_resources-3.0.0-py2.7.egg', '/Library/Python/2.7/site-packages/filelock-3.0.12-py2.7.egg', '/Library/Python/2.7/site-packages/distlib-0.3.1-py2.7.egg', '/Library/Python/2.7/site-packages/appdirs-1.4.4-py2.7.egg']&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help me to resolve the error and import the modules to the script ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Aug 2022 19:31:33 GMT</pubDate>
    <dc:creator>Bonthala_Deepu</dc:creator>
    <dc:date>2022-08-12T19:31:33Z</dc:date>
    <item>
      <title>Unable to import python external modules in nifi execute script</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Unable-to-import-python-external-modules-in-nifi-execute/m-p/350048#M235858</link>
      <description>&lt;P&gt;Tried executing following python script body &amp;amp; Module directory as&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import json
import java.io
from org.apache.commons.io import IOUtils
from java.nio.charset import StandardCharsets
from org.apache.nifi.processor.io import StreamCallback
#from google.cloud import bigquery
#from google.oauth2 import service_account
import google

class ModJSON(StreamCallback):
    def __init__(self):
        pass
    def process(self, inputStream, outputStream):
        text = IOUtils.toString(inputStream, StandardCharsets.UTF_8)
        obj = json.loads(text)
        print(text)
        outputStream.write(bytearray(json.dumps(obj, indent=4).encode('utf-8')))

flowFile = session.get()
if (flowFile != None):
  flowFile = session.write(flowFile, ModJSON())
  flowFile = session.putAttribute(flowFile, "filename", flowFile.getAttribute('filename')+'_translated.json')
  session.transfer(flowFile, REL_SUCCESS)
session.commit()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Module Directory&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/Users/bonthala/Library/Python/2.7/lib/python/site-packages/&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Received the following error&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;2022-08-13 00:14:56,948 ERROR [Timer-Driven Process Thread-6] o.a.nifi.processors.script.ExecuteScript ExecuteScript[id=8df016ea-0182-1000-35d7-40765b666df2] Failed to properly initialize Processor. If still scheduled to run, NiFi will attempt to initialize and run the Processor again after the 'Administrative Yield Duration' has elapsed. Failure is due to org.apache.nifi.processor.exception.ProcessException: Could not instantiate script engines: java.io.IOException: Mark invalid
↳ causes: java.io.IOException: Mark invalid
	at java.base/java.io.BufferedReader.reset(BufferedReader.java:517)
	at org.python.core.ParserFacade.parseExpressionOrModule(ParserFacade.java:133)
	at org.python.util.PythonInterpreter.compile(PythonInterpreter.java:320)
	at org.python.util.PythonInterpreter.compile(PythonInterpreter.java:316)
	at org.python.util.PythonInterpreter.compile(PythonInterpreter.java:308)
	at org.python.jsr223.PyScriptEngine.compileScript(PyScriptEngine.java:87)
	at org.python.jsr223.PyScriptEngine.compile(PyScriptEngine.java:76)
	at org.apache.nifi.script.impl.JythonScriptRunner.&amp;lt;init&amp;gt;(JythonScriptRunner.java:42)
	at org.apache.nifi.script.ScriptRunnerFactory.createScriptRunner(ScriptRunnerFactory.java:56)
	at org.apache.nifi.script.ScriptingComponentHelper.setupScriptRunners(ScriptingComponentHelper.java:250)
	at org.apache.nifi.script.ScriptingComponentHelper.setupScriptRunners(ScriptingComponentHelper.java:211)
	at org.apache.nifi.processors.script.ExecuteScript.setup(ExecuteScript.java:176)
	at jdk.internal.reflect.GeneratedMethodAccessor552.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:145)
	at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:133)
	at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:78)
	at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotation(ReflectionUtils.java:55)
	at org.apache.nifi.controller.StandardProcessorNode.lambda$initiateStart$6(StandardProcessorNode.java:1653)
	at org.apache.nifi.engine.FlowEngine$3.call(FlowEngine.java:123)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
java.io.IOException: java.io.IOException: Mark invalid

↳ causes: javax.script.ScriptException: java.io.IOException: java.io.IOException: Mark invalid
↳ causes: org.apache.nifi.processor.exception.ProcessException: Could not instantiate script engines
org.apache.nifi.processor.exception.ProcessException: Could not instantiate script engines
	at org.apache.nifi.script.ScriptingComponentHelper.setupScriptRunners(ScriptingComponentHelper.java:256)
	at org.apache.nifi.script.ScriptingComponentHelper.setupScriptRunners(ScriptingComponentHelper.java:211)
	at org.apache.nifi.processors.script.ExecuteScript.setup(ExecuteScript.java:176)
	at jdk.internal.reflect.GeneratedMethodAccessor552.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:145)
	at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:133)
	at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:78)
	at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotation(ReflectionUtils.java:55)
	at org.apache.nifi.controller.StandardProcessorNode.lambda$initiateStart$6(StandardProcessorNode.java:1653)
	at org.apache.nifi.engine.FlowEngine$3.call(FlowEngine.java:123)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: javax.script.ScriptException: java.io.IOException: java.io.IOException: Mark invalid
	at org.python.jsr223.PyScriptEngine.scriptException(PyScriptEngine.java:226)
	at org.python.jsr223.PyScriptEngine.compileScript(PyScriptEngine.java:93)
	at org.python.jsr223.PyScriptEngine.compile(PyScriptEngine.java:76)
	at org.apache.nifi.script.impl.JythonScriptRunner.&amp;lt;init&amp;gt;(JythonScriptRunner.java:42)
	at org.apache.nifi.script.ScriptRunnerFactory.createScriptRunner(ScriptRunnerFactory.java:56)
	at org.apache.nifi.script.ScriptingComponentHelper.setupScriptRunners(ScriptingComponentHelper.java:250)
	... 16 common frames omitted
Caused by: org.python.core.PyException: null
	at org.python.core.Py.JavaError(Py.java:552)
	at org.python.core.ParserFacade.fixParseError(ParserFacade.java:107)
	at org.python.core.ParserFacade.parseExpressionOrModule(ParserFacade.java:136)
	at org.python.util.PythonInterpreter.compile(PythonInterpreter.java:320)
	at org.python.util.PythonInterpreter.compile(PythonInterpreter.java:316)
	at org.python.util.PythonInterpreter.compile(PythonInterpreter.java:308)
	at org.python.jsr223.PyScriptEngine.compileScript(PyScriptEngine.java:87)
	... 20 common frames omitted
Caused by: java.io.IOException: Mark invalid
	at java.base/java.io.BufferedReader.reset(BufferedReader.java:517)
	at org.python.core.ParserFacade.parseExpressionOrModule(ParserFacade.java:133)
	... 24 common frames omitted&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Python sys path&lt;/P&gt;&lt;LI-CODE lang="python"&gt;~ » python                                                                                                                                                              bonthala@Offfice-Admins-MacBook-Pro

WARNING: Python 2.7 is not recommended.
This version is included in macOS for compatibility with legacy software.
Future versions of macOS will not include Python 2.7.
Instead, it is recommended that you transition to using 'python3' from within Terminal.

Python 2.7.16 (default, Jul  5 2020, 02:24:03)
[GCC 4.2.1 Compatible Apple LLVM 11.0.3 (clang-1103.0.29.21) (-macos10.15-objc- on darwin
Type "help", "copyright", "credits" or "license" for more information.
&amp;gt;&amp;gt;&amp;gt; import sys
&amp;gt;&amp;gt;&amp;gt; sys.path
['', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/Users/bonthala/Library/Python/2.7/lib/python/site-packages', '/Library/Python/2.7/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '/Library/Python/2.7/site-packages/virtualenv-20.0.27-py2.7.egg', '/Library/Python/2.7/site-packages/importlib_resources-3.0.0-py2.7.egg', '/Library/Python/2.7/site-packages/filelock-3.0.12-py2.7.egg', '/Library/Python/2.7/site-packages/distlib-0.3.1-py2.7.egg', '/Library/Python/2.7/site-packages/appdirs-1.4.4-py2.7.egg']&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help me to resolve the error and import the modules to the script ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2022 19:31:33 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Unable-to-import-python-external-modules-in-nifi-execute/m-p/350048#M235858</guid>
      <dc:creator>Bonthala_Deepu</dc:creator>
      <dc:date>2022-08-12T19:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to import python external modules in nifi execute script</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Unable-to-import-python-external-modules-in-nifi-execute/m-p/350546#M236009</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;BR /&gt;I'm not 100% sure, but I think you mix some things up. NiFi is written in Java and therefore running in the JVM. In NiFi you can run Jython which is a Python implementation in Java.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I guess you are trying to use CPython (mostly the default Python) modules / packages in Jython (Java-Python) which does not work. Maybe you are importing them wrong.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2022 15:14:58 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Unable-to-import-python-external-modules-in-nifi-execute/m-p/350546#M236009</guid>
      <dc:creator>janis-ax</dc:creator>
      <dc:date>2022-08-22T15:14:58Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to import python external modules in nifi execute script</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Unable-to-import-python-external-modules-in-nifi-execute/m-p/358192#M237762</link>
      <description>&lt;P&gt;I get the same error with a very simple import:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;try&lt;BR /&gt;&amp;nbsp; &amp;nbsp; import org.apache.commons.io&lt;BR /&gt;&amp;nbsp; &amp;nbsp; direct_nifi = True&lt;BR /&gt;except ImportError:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; direct_nifi = False&lt;/PRE&gt;&lt;DIV&gt;nifi-app.log&lt;/DIV&gt;&lt;PRE&gt;2022-11-22 14:11:52,536 INFO [pool-7-thread-1] o.a.n.c.r.WriteAheadFlowFileRepository Initiating checkpoint of FlowFile Repository&lt;BR /&gt;2022-11-22 14:11:52,537 INFO [pool-7-thread-1] o.a.n.c.r.WriteAheadFlowFileRepository Successfully checkpointed FlowFile Repository with 0 records in 0 milliseconds&lt;BR /&gt;2022-11-22 14:11:55,817 INFO [NiFi Web Server-137] o.a.n.c.s.StandardProcessScheduler Running once ExecuteScript[id=a00fd11d-0184-1000-fa55-6eabbd1be8fe]&lt;BR /&gt;2022-11-22 14:11:55,817 INFO [NiFi Web Server-137] o.a.n.controller.StandardProcessorNode Starting ExecuteScript[id=a00fd11d-0184-1000-fa55-6eabbd1be8fe]&lt;BR /&gt;2022-11-22 14:11:56,119 INFO [Flow Service Tasks Thread-2] o.a.nifi.controller.StandardFlowService Saved flow controller org.apache.nifi.controller.FlowController@6eea35ff // Another save pending = false&lt;BR /&gt;2022-11-22 14:11:56,765 ERROR [Timer-Driven Process Thread-5] o.a.nifi.processors.script.ExecuteScript ExecuteScript[id=a00fd11d-0184-1000-fa55-6eabbd1be8fe] Failed to properly initialize Processor. If still scheduled to run, NiFi will attempt to initialize and run the Processor again after the 'Administrative Yield Duration' has elapsed. Failure is due to org.apache.nifi.processor.exception.ProcessException: Could not instantiate script engines&lt;BR /&gt;org.apache.nifi.processor.exception.ProcessException: Could not instantiate script engines&lt;BR /&gt;at org.apache.nifi.script.ScriptingComponentHelper.setupScriptRunners(ScriptingComponentHelper.java:256)&lt;BR /&gt;at org.apache.nifi.script.ScriptingComponentHelper.setupScriptRunners(ScriptingComponentHelper.java:211)&lt;BR /&gt;at org.apache.nifi.processors.script.ExecuteScript.setup(ExecuteScript.java:178)&lt;BR /&gt;at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)&lt;BR /&gt;at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)&lt;BR /&gt;at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)&lt;BR /&gt;at java.base/java.lang.reflect.Method.invoke(Method.java:568)&lt;BR /&gt;at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:145)&lt;BR /&gt;at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:133)&lt;BR /&gt;at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:78)&lt;BR /&gt;at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotation(ReflectionUtils.java:55)&lt;BR /&gt;at org.apache.nifi.controller.StandardProcessorNode.lambda$initiateStart$8(StandardProcessorNode.java:1733)&lt;BR /&gt;at org.apache.nifi.engine.FlowEngine$3.call(FlowEngine.java:123)&lt;BR /&gt;at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)&lt;BR /&gt;at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)&lt;BR /&gt;at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)&lt;BR /&gt;at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)&lt;BR /&gt;at java.base/java.lang.Thread.run(Thread.java:833)&lt;BR /&gt;Caused by: javax.script.ScriptException: SyntaxError: mismatched input '\r\n' expecting COLON in &amp;lt;script&amp;gt; at line number 23 at column number 3&lt;BR /&gt;at org.python.jsr223.PyScriptEngine.scriptException(PyScriptEngine.java:213)&lt;BR /&gt;at org.python.jsr223.PyScriptEngine.compileScript(PyScriptEngine.java:93)&lt;BR /&gt;at org.python.jsr223.PyScriptEngine.compile(PyScriptEngine.java:76)&lt;BR /&gt;at org.apache.nifi.script.impl.JythonScriptRunner.&amp;lt;init&amp;gt;(JythonScriptRunner.java:42)&lt;BR /&gt;at org.apache.nifi.script.ScriptRunnerFactory.createScriptRunner(ScriptRunnerFactory.java:56)&lt;BR /&gt;at org.apache.nifi.script.ScriptingComponentHelper.setupScriptRunners(ScriptingComponentHelper.java:250)&lt;BR /&gt;... 17 common frames omitted&lt;BR /&gt;Caused by: org.python.core.PySyntaxError: SyntaxError: mismatched input '\r\n' expecting COLON (&amp;lt;script&amp;gt;, line 23)&lt;BR /&gt;at org.python.core.ParserFacade.fixParseError(ParserFacade.java:95)&lt;BR /&gt;at org.python.core.ParserFacade.parseExpressionOrModule(ParserFacade.java:136)&lt;BR /&gt;at org.python.util.PythonInterpreter.compile(PythonInterpreter.java:321)&lt;BR /&gt;at org.python.util.PythonInterpreter.compile(PythonInterpreter.java:317)&lt;BR /&gt;at org.python.util.PythonInterpreter.compile(PythonInterpreter.java:309)&lt;BR /&gt;at org.python.jsr223.PyScriptEngine.compileScript(PyScriptEngine.java:87)&lt;BR /&gt;... 21 common frames omitted&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 22 Nov 2022 17:16:42 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Unable-to-import-python-external-modules-in-nifi-execute/m-p/358192#M237762</guid>
      <dc:creator>lgallindo</dc:creator>
      <dc:date>2022-11-22T17:16:42Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to import python external modules in nifi execute script</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Unable-to-import-python-external-modules-in-nifi-execute/m-p/358213#M237773</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you help to run a python script in NIFI containing an external package i.e.,&amp;nbsp;&lt;STRONG&gt;import google&lt;/STRONG&gt; in this case?&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2022 09:26:40 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Unable-to-import-python-external-modules-in-nifi-execute/m-p/358213#M237773</guid>
      <dc:creator>Bonthala_Deepu</dc:creator>
      <dc:date>2022-11-23T09:26:40Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to import python external modules in nifi execute script</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Unable-to-import-python-external-modules-in-nifi-execute/m-p/358215#M237774</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/102004"&gt;@lgallindo&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Seems this is a syntax error. See the following error log&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Caused by: javax.script.ScriptException: SyntaxError: mismatched input '\r\n' expecting COLON in &amp;lt;script&amp;gt; at line number 23 at column number 3&lt;BR /&gt;at org.python.jsr223.PyScriptEngine.scriptException(PyScriptEngine.java:213)&lt;BR /&gt;at org.python.jsr223.PyScriptEngine.compileScript(PyScriptEngine.java:93)&lt;BR /&gt;at org.python.jsr223.PyScriptEngine.compile(PyScriptEngine.java:76)&lt;BR /&gt;at org.apache.nifi.script.impl.JythonScriptRunner.&amp;lt;init&amp;gt;(JythonScriptRunner.java:42)&lt;BR /&gt;at org.apache.nifi.script.ScriptRunnerFactory.createScriptRunner(ScriptRunnerFactory.java:56)&lt;BR /&gt;at org.apache.nifi.script.ScriptingComponentHelper.setupScriptRunners(ScriptingComponentHelper.java:250)&lt;BR /&gt;... 17 common frames omitted&lt;BR /&gt;Caused by: org.python.core.PySyntaxError: SyntaxError: mismatched input '\r\n' expecting COLON (&amp;lt;script&amp;gt;, line 23)&lt;BR /&gt;at org.python.core.ParserFacade.fixParseError(ParserFacade.java:95)&lt;BR /&gt;at org.python.core.ParserFacade.parseExpressionOrModule(ParserFacade.java:136)&lt;BR /&gt;at org.python.util.PythonInterpreter.compile(PythonInterpreter.java:321)&lt;BR /&gt;at org.python.util.PythonInterpreter.compile(PythonInterpreter.java:317)&lt;BR /&gt;at org.python.util.PythonInterpreter.compile(PythonInterpreter.java:309)&lt;BR /&gt;at org.python.jsr223.PyScriptEngine.compileScript(PyScriptEngine.java:87)&lt;BR /&gt;... 21 common frames omitted&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Nov 2022 09:29:02 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Unable-to-import-python-external-modules-in-nifi-execute/m-p/358215#M237774</guid>
      <dc:creator>Bonthala_Deepu</dc:creator>
      <dc:date>2022-11-23T09:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to import python external modules in nifi execute script</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Unable-to-import-python-external-modules-in-nifi-execute/m-p/372616#M241310</link>
      <description>&lt;P&gt;Was getting the same error with some of our Python/Jython scripts and how I got it to work was remove the modules path from "Module Directory" and add it with the following at the very top of your script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;import&lt;/SPAN&gt; &lt;SPAN&gt;sys&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;sys&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;path&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;append&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"/Users/bonthala/Library/Python/2.7/lib/python/site-packages/"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 14 Jun 2023 19:05:39 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Unable-to-import-python-external-modules-in-nifi-execute/m-p/372616#M241310</guid>
      <dc:creator>joseomjr</dc:creator>
      <dc:date>2023-06-14T19:05:39Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to import python external modules in nifi execute script</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Unable-to-import-python-external-modules-in-nifi-execute/m-p/375681#M242589</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/105558"&gt;@joseomjr&lt;/a&gt;&amp;nbsp;I am trying to replicate your suggested method, please answer did you include the import command after sys.path.append command?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Aug 2023 14:07:02 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Unable-to-import-python-external-modules-in-nifi-execute/m-p/375681#M242589</guid>
      <dc:creator>Kiranq</dc:creator>
      <dc:date>2023-08-28T14:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to import python external modules in nifi execute script</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Unable-to-import-python-external-modules-in-nifi-execute/m-p/375682#M242590</link>
      <description>&lt;P&gt;The 2 lines I provided are the very first lines and then all your code comes after.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Aug 2023 14:10:21 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Unable-to-import-python-external-modules-in-nifi-execute/m-p/375682#M242590</guid>
      <dc:creator>joseomjr</dc:creator>
      <dc:date>2023-08-28T14:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to import python external modules in nifi execute script</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Unable-to-import-python-external-modules-in-nifi-execute/m-p/375683#M242591</link>
      <description>&lt;P&gt;Thanks for the reply.&lt;BR /&gt;I did it in the same way you have mentioned (I am importing Selenium module and from this module, Service,&amp;nbsp;&lt;SPAN&gt;WebDriverWait and EC components are imported&lt;/SPAN&gt;&lt;SPAN&gt;) but late in the code execution, my scripts gives an error "global name Service is not defined".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Any idea whats causing the issue?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Aug 2023 14:50:02 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Unable-to-import-python-external-modules-in-nifi-execute/m-p/375683#M242591</guid>
      <dc:creator>Kiranq</dc:creator>
      <dc:date>2023-08-28T14:50:02Z</dc:date>
    </item>
  </channel>
</rss>

