pythonpowershellpower-automate-desktop

Power Automate Desktop '[Errno 2] No such file or directory when running powershell script


I am trying to use power automate desktop to run a python script. Since power automate desktop does not have an action to run a python3 script (only python 2), I have to use the run powershell script action instead. I am passing the path to my python interpreter and the absolute path to my python script. However, when I run the flow, I get:

C:\Python27\python.exe: can't open file 'C:\Users\myname\Source\Repos\Projects\Solution\HQ': [Errno 2] No such file or directory

It is cutting off the rest of my path because there is white space, which I wasn't aware was an issue when creating the repository that my scripts are in. Is there a way around running the powershell script to acknowledge the rest of the path without having to rename anything?


Solution

  • When you're calling your Python script via PowerShell, make sure both the path to the Python interpreter and the script path are enclosed in quotes. Your command should look something like this:

    & "C:\Path\To\Python3\python.exe" "C:\Users\myname\Source\Repos\Projects\Solution\HQ My Script.py"