Invoke Python Method getting error

I am trying to invoke this python code using invoke method activity of UiPath. This code simply extracts the data from the qr code. I have stored qr code in png format.

def extract(imagepath):
import cv2
# Read the image using OpenCV
image = cv2.imread(imagepath)

# Initialize the QR code detector
detector = cv2.QRCodeDetector()

# Detect and decode the QR code
data, bbox, _ = detector.detectAndDecode(image)

if data:
    return data
else:
    return None

But I am getting error Invoke Python Method: One or more errors occurred. (Error invoking Python method). I am passing path name dynamically too. To test whether there are some installation issues or not for that I created another small sequence to invoke addition code that is working completely fine means python and .net runtime has been properly installed.

Hi @bharat.c

Could you play a bit with the file path (hard code it for the text)? I think it might be the issue here.

Basically, it would help if you could test your script by starting with just the first line, testing, and then adding another few lines if it worked and testing again. It would help to know which part of the script is causing this issue.

Hey Maciej,
I tried doing this, but the error still persists.