cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jack_Melvin
Regular Visitor

Using Python Script with Modules in Power Automate Desktop

Hi All,

 

I am trying to run a python script with the getpass module. I have put the module into a folder and given the path to Power Automate Desktop. I keep getting this error. Any suggestions?

 

 

python Error.jpgPython ScriptPython Script

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Jack_Melvin, sorry I wasn't more clear. I was assuming (maybe wrongly) that the Python folder on your desktop contains version 2.7. If it doesn't (if it's Python 3 for instance) you would need to install Python 2.7 somewhere. You don't need to add it to your path, PAD just needs to be able to find the 2.7 modules/libs so PAD's IronPython can import from there.

Here's my code in the Action.

 

 

 

import sys
sys.path.append(r"c:\Python27\Lib")
import getpass
machineUserName = getpass.getuser()
print machineUserName

 

 

 

 Here is what you'll have to put in (changing "JackMelvin" to what I can't read to what it is in the actual path):

 

 

 

import sys
sys.path.append(r"C:\Users\JackMelvin\Desktop\Python\Mods")
import getpass
machineUserName = getpass.getuser()
print machineUserName

 

 

 

 

 You might look in that folder to make sure 'getpass.py' is in there.

View solution in original post

6 REPLIES 6
fraenK
Memorable Member
Memorable Member

Are you aware that PAD is using IronPython, version 2.7.9.1?

burque505
Helper V
Helper V

@Jack_Melvin, here you go. Just needs the path to your modules to be changed to what you have.

Also, you were using Python 3 syntax for the print statement, which I always forget and do myself. 😀

 

working.png

No I wasn't, I am unfamiliar with IronPython. What does it allow us to do? 

@burque505, I copied your code and I am receiving the same error. Would you please explain what your code is doing so I can fix mine. 

 

Thanks,

Hi @Jack_Melvin, sorry I wasn't more clear. I was assuming (maybe wrongly) that the Python folder on your desktop contains version 2.7. If it doesn't (if it's Python 3 for instance) you would need to install Python 2.7 somewhere. You don't need to add it to your path, PAD just needs to be able to find the 2.7 modules/libs so PAD's IronPython can import from there.

Here's my code in the Action.

 

 

 

import sys
sys.path.append(r"c:\Python27\Lib")
import getpass
machineUserName = getpass.getuser()
print machineUserName

 

 

 

 Here is what you'll have to put in (changing "JackMelvin" to what I can't read to what it is in the actual path):

 

 

 

import sys
sys.path.append(r"C:\Users\JackMelvin\Desktop\Python\Mods")
import getpass
machineUserName = getpass.getuser()
print machineUserName

 

 

 

 

 You might look in that folder to make sure 'getpass.py' is in there.

View solution in original post

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (2,043)