Invoke Python Method: Pipe is broken

I’m trying to load a python script in my project when I called “Invoke python method” I’m getting pipe is broken error. Could someone help me on this


Have a look below thread.

Hi @VC365,

Pipe is broken is a very abstract error in .net and C# and with minimal root cause. I have wasted a lot of time trying to find out why this happens without a concrete answer in the forums or in stackoverflow.

In my view, the amount of data being sent from one activity to another or one workflow to another throws “Pipe is broken.” error in UiPath. I suspect that your python code returns an object (json, og other object from python to .net) which is of a large size.

What is large?
In my tests on datatables, I found that if the datatable has more than 8000 rows and you are trying to send this to another workflow to process, then there are more chances for the “Pipe is broken” error in UiPath. In my case, I faced this error while finding unique values in a column within a large datatable (>8000 rows) and passed the datatable to another workflow. My solution was to not send the datatable to another workflow, but to process it right there within the process.

My suggestion:
Try/test by reducing the size of the object returned from Python by slicing the returned value. If that does not work please try and convert your return object to a json string.

In UiPath you can easily deserialize the return string from Python to get the json object and do any manipulations on it. Please refer this post to know how to do this from the python code and integrate this within UiPath: How to use permuation and combination in excel uipath - Help - UiPath Community Forum

Hope this gives you some ideas. Goodluck!

@jeevith thanks for the reply I have got to know the reason behind it my script takes a PDF file as input and converts checkboxes within it to yes and no and then coverts back to PDFS using some packages like tensonflow etc. May i know what can be the size to avoid pipe is broken error. BTW my script is not returning anything it just performs some actions on file and then places in specified path.
FYI here is one more query I posted related to my issue which was not resolved so I had to choose this option to convert them
How do I read a checkbox from a PDF using Document understanding framework.

Hi @VC365,

Interesting. So nothing is actually being passed as object to UiPath from the python script.

Ok can you tell us what are you returning from the python function? Would help if you paste your function’s code here.

def something(input):
   return  ??

If you are just returning a flag, it is interesting to see the Pipe is broken error occur in UiPath

@jeevith here is my main method
def main(*args):
start_time =

cbs = CheckBoxSolver(template_path,input_pdf_path,output_pdf_directory,model_path)

end_time =

print('Duration: {}'.format(end_time - start_time))


output_pdf_directory = “./output”
model_path = r’./model/checkbox_classifier_model.hdf5’
template_path = r’./templates’

if name == “main”:
parser = argparse.ArgumentParser()
parser.add_argument("–file_path",help=‘Pdf Input File Path’)

args = parser.parse_args()

if args.file_path:
    input_pdf_path = args.file_path
    print("Pdf Input File Path Required...")

Hi @VC365 ,

Did you find any solution? I’m also getting the same error. I’m trying to extract data from PDF invoices.

Hi @VC365 and @sri_e,

I forgot to reply here.
From @VC365 I see that the return value is within a main function, which UiPath Invoke Python will not support.

  • What I suggest is you do all the processing using a helper function, call that helper function in another function with all required inputs.

  • Then call this function from UiPath Invoke Python.

The best way to get information back is using Json. So in short the function you call from UiPath should contain a return within it.

return (json_value) 

For example

def process_case(inputs):
    processedpdf = "your logic"
    return (processedpdf) 

def call_function_uipath(inputs):
    import json
    result = process_case(inputs)
    json_value = json.loads(result)
    return (json_value)

Thank you @jeevith for information. I will try and update back here.