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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Automate
Answered

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.
Screenshot 2024-09-26 101621.png
Screenshot 2024-09-26 101522.png
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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 589

#2
Valantis Profile Picture

Valantis 328

#3
David_MA Profile Picture

David_MA 284 Super User 2026 Season 1

Last 30 days Overall leaderboard