Run Python script Action(Power Automate Desktop)

Japanese version.

This Action that executes arbitrary Python.

This is effective for processing that would be difficult to handle with actions alone, but because it involves entering the program code itself, it is recommended that it be used only minimally in environments used by non-systems engineers.

However, complex conditional expressions are too large to be built with actions, so there are cases where code is more appropriate.

How to use

Drag "Run Python script" from "Scripting" under "Actions".

Set parameters.


Python script to run

Specifies the Python script to run.

Power Automate Desktop variables are available in this (enclose the variable name in %).

The basic form is then to output the result with "print" and receive it in the Variables produced PythonScriptOutput.

Code example.

In this example, the result is the Power Automate Desktop variable (NewVar) plus 5.

It is possible to read the value of a Power Automate Desktop variable.
However, it is not possible to set the value in reverse (a runtime error will occur).

Variables produced as a result.

Module folder paths

Specify if you want to load and use Python files.

Variables produced

Stores the result of executing "Python script to run".


The results of Python execution and standard output are stored.

The standard output is set when the code is specified as follows.

print content

This can be used to return calculation results to flow.

Code example.
Variables produced as a result.


Python runtime and syntax errors are set.

For those who want to learn Power Automate Desktop effectively

The information on this site is now available in an easy-to-read e-book format.

Or Kindle Unlimited (unlimited reading).

You willl discover how to about basic operations.

By the end of this book, you will be equipped with the knowledge you need to use Power Automate Desktop to streamline your workflow.

Table of Contents.

Update History.

For those who want to learn Python efficiently.

The information on this site is now available in an easy-to-read e-book format for $3.00.

Or Kindle Unlimited (unlimited reading).

This textbook is used for new employees with no programming experience.

This book focuses on basic programming topics.

We do not cover topics such as object-oriented programming, statistical analysis using Python-specific libraries, machine learning, as these topics are difficult to understand from the standpoint of initial programming learning.

This book is especially recommended for those who have no experience with programming.


Scripting Actions