Solution is to use ExecuteStreamCommand option. The reason is ExecuteScript in nifi is not pure python instead it's jython. So, to execute a python code, we only need to set the python path and the file path. The configuration for this can be seen from the image attached below.