Excuse me, i’m going to use you thread to ask the same exact question.
I need to call a python script but it doesnt work.
I made a test script with output 5 random numbers:
3
5
7
1
6
i need those numbers to be writen to a file.csv so kantu can read those numbers by reading the csv file.
When i try the script on the command line all is ok
c:\python\scripts\testkantu.py > test.csv
The csv file is created with the 5 random numbers
But when i use xrun to call the script
kantu finish without error but the file is not created, also the python script can use a seed to generate the numbers, like testkantu.py 5 if i want the seed to be a variable can i use
“Value”: “${seed} > test.csv”?
so the line is c:\python\scripts\testkantu.py 5 > test.csv
# XRUN Python V1.0
import sys
#get command line value
i = int (sys.argv[1])
#Square it!
i = i * i
# exit code in Python (limited to value between 0...255)
sys.exit(i)
Thank you for your help, but calling the python script is not my issue, i used the thread, but my problem is i need the output from the python script to be saved into a csv so i can process it later,
1 i get data from web
2 i process the data with python and get a csv
3 i read the csv and
4 do funny things.
XRunAndWait is no shell command line. You can not use operators like “>”. The solution is to code the “write to CSV” inside the Python itself. The job of XRunAndWait is only to start the script.
I know this thread is older, but I wanted to share a PowerShell-based approach that I’ve found useful for running Python scripts from UI.Vision—especially when passing parameters or handling paths with spaces.
Solution: Run Python via PowerShell
Here’s a UI.Vision XRun command snippet that:
Sets an environment variable (YOURPARAMETER) before execution.
Launches a Python script (even with spaces in the path).
{
"Command": "XRun",
"Target": "powershell.exe",
"Value": "$env:YOURPARAMETER='1'; Start-Process 'C:\\Python\\python.exe' -ArgumentList '\\\"${whereUI}\\UI\\logs\\YOUR SCRIPT.py\\\"';",
"Description": "Run Python script with PowerShell and pass a parameter"
}
Key Details:
Why PowerShell? It handles environment variables and paths more robustly than plain cmd.
Parameter Usage: The $env:YOURPARAMETER='1' sets a variable accessible in Python via:
import os param_value = os.environ.get('YOURPARAMETER') # Returns '1'
Path Safety: The triple backslashes (\\\") escape spaces in file paths correctly.
Example Use Case:
I use this to trigger log cleanup from UI.Vision. If the script is launched via RPA, YOURPARAMETER=1 tells Python to process the latest UI.Vision log.
You can use XRunWait (to wait for execution to finish)