Aggregate Exception occurs during load python script

Hi Experts,

I am trying to load python script having class, but uipath throwing error as below

If any one tried on calling python script with classes, pls help me.

Hello @Vineeth_Burle,

This probably is due to how the Python activity is built in UiPath.

If you are trying to access a method from your class you have to ensure two things

  1. Your class method is returning a value
  2. You have instantiated your class method within another root function and also returned the value from it

For example:

class Person:
"""
Your class and its methods
"""
    def __init__(self, name, age):
        self.name = name
        self.age = age

    def myfunc(self):
        OutputString = "Hello my name is {0} and I am {1} old.".format(self.name,self.age)
        print (OutputString )

        # Have to return a value here for it to work in UiPath
        return (OutputString)


def PersonInstance(PersonName, Age):
"""
We instantiate the class here manually so that UiPath can 
access this simple method instead. 

We will call this method instead of the class method above in UiPath
"""
    p1 = Person(PersonName, Age)
    
   # Have to return a value here for it to work in UiPath
    return p1.myfunc()

You can also refer this thread : Python script with Class and object - Learn / Academy Feedback - UiPath Community Forum