I am trying to execute a python script in executestreamcommand processor. The script takes the flowfile via STDIN and writes to ADLS. When I configured and run the processors, I am getting the create processerror = 193 error. Google search sows that the script has to be executed as a ShellExecute. I dont get what it is. Can anyone provide me that command I should pass in the commandarguments property of the executestreamcommand processor. Thanks for the help.
It would be important to see the command itself and the call of it to be sure. But if you are using the Win32 API call CreateProcess you can only call programs in the EXE format. Especially you are not able to call any shell script or jar with it.
Should I understand that I cannot execute a script but only a.exe application.? Because I want to connect to Azure datalake through aPython script and when I use Executescript processor, nifi is not identifying all modules related to azure that I import in the python script. Kindly help.
This depends on the call you actually make. If you end up calling CreateProcess of the Win32 API this is true (you can only start an exe application with that API call). And your error message makes this quite likely, as that's the exact error you get from the Win32 API.
You start the Python script locally? On a Windows machine? And is your local Python script making the call? Or is it the Nifi Flow calling a Python script on the server that is failing? Or maybe the server side Python script makes a call that fails?
Is this what your are basically following: https://community.hortonworks.com/articles/35568/python-script-in-nifi.html , or are you more or less following this https://community.hortonworks.com/questions/106802/execute-python-script-with-nifi.html
Are you defining the script inside the ExecuteScript processor, or are you calling an existing script with the ExecuteProcess or ExecuteStreamProcess processor? In the last case the answer from Matt includes a hint to your issue:
if you are using "pure" Python modules (meaning their code and dependencies are all Python and do not use natively compiled modules -- no CPython or .so/.dll, etc. -- you can use ExecuteScript or InvokeScriptedProcessor. This uses a Jython (not Python) engine to execute your script.
I’m following as per the first link you have provided. My python script is locally present on my windows desktop and I provide the path of the script in the executestreamcommand configuration. To an extent all packages of python azure uses .py files but I’m not sure if those packages in turn uses any other .so or jar files. With respect to your answer on making calls to win32 API, I don’t know how can I control it if it should be create process or shell execute. In fact that is the idea I’m looking for here. My understanding from google research is that we can execute any python script using the local python engine using executestreamcommand processor provided you configure it to make a shellexecute command.
Right now I’m not providing any command in the command argument and so it by default takes my script as . exe and failing. Just for an idea how we execute the script from our command prompt, “ full path of python.exe full path of script file arguments” if we can give a command similar to this in the executecommandprocessor, it may work.
All these are just my understanding based on the details I collected. If you can help me much appreciated. Thank you so much for your quick responses as well.
Ok, then let's try the following:
Command Path: full path of python.exe
Command Arguments: full path of script file; arguments
This way you would be actually calling an exe, as needed, and the arguments should let your Python interpreter start your python script.
@Harald Berghoff @Matt Burgess
I don't see a luck. I am giving full path with python.exe in the command argument. Full path of script file including script name.py in the command path. I still see the same error.
I looks like its working Harald. There was a small mistake in the path of script which after corrected, is executing the script. I am able to see the print statements in the governance data of the ExecuteStreamCommand processor. However I don't see or confirm if it has connected to ADL or not as I don't see any files written in the folder I specify. I will continue to research but if you have some thoughts, please let me know. As of now, it doesn't give me any import error (of Azure packages) or any other dependency errors.