web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Automate
Unanswered

Run Python Scirpt

(1) ShareShare
ReportReport
Posted on by 5

I am trying to run this script using run python script action of power automate desktop. I am imported this script as module in the flow. But I am unable to run this script. I am facing challenges and the script is throwing errors related to the library. I am attaching a snapshot of the same.

 
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:
print data
else:
print None

In my downloads folder this file is stored as QR_Final.py.
I have the same question (0)
  • Verified answer
    harish_sada Profile Picture
    53 on at

    Steps to decode a QR code

    Since the Run Python script action in Power Automate only supports Python 3.4, and OpenCV is not compatible with that version, follow the steps below to decode QR codes using a more recent Python version.

    1. install python in your system 3.12
    2. install Opencv through CMD (pip install opencv-python, pip install pyzbar)
     

    3. Open notepad paste the code provided below, and save the file with a .py extension

    import cv2
    from pyzbar.pyzbar import decode
    import sys

    file_path=sys.argv[1]

    image = cv2.imread(file_path)

    qr_codes = decode(image)

    for qr in qr_codes:
        qr_data = qr.data.decode('utf-8')
        print(f"Decoded QR Code: {qr_data}")
     
     
    4. Use Run power shell script action, and pass the path of your Python file and the image file path as inputs.
     
     
     
     
     
     
     
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard