Support Questions
Find answers, ask questions, and share your expertise

ExecuteScript with python 3

New Contributor

I am trying to use the ExecuteScript processor to run a python program that connects to irc and posts messages. I have python3 on my system but when I paste the python code into the ExecuteScript processor I get the following error:

Unable to load script: TypeError: str() takes at most 1 arguments (2 given) in <script> at line number 14: javax.script.ScriptException: TypeError: str() takes at most 1 arguments (2 given) in <script> at line number 14

javax.script.ScriptException: AttributeError: 'NoneType' object has no attribute 'strip' in

that line of code looks like below:




ircsock.send(bytes("USER "+ botnick +" "+ botnick +" "+ botnick + " " + botnick + "\n", "UTF-8"))
ircmsg = ircmsg.strip('\n\r')



in the python script I am pointing to python3 



import socket

ircsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)




How can i get the ExecuteScript processor to use python3? I believe the issue is that NiFi is still using python 2.7 in /usr/bin. 




Why don't you try with ExecuteStreamCommand as shown here:

New Contributor

I first set it up with executestream and was successful in getting it to work. Isn't it better to use invokescript or executescript because then there isn't a need to maintain scripts outside of NiFi? I just thought it would be better to natively pass the flowfile using flowfile = session.get().

; ;